Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save AustinMaddox/6371333 to your computer and use it in GitHub Desktop.

Select an option

Save AustinMaddox/6371333 to your computer and use it in GitHub Desktop.
Fitment part number request service PHP example.The WPS Fitment Part Number Request web service is meant to find all the parts associated to a single vehicle. Below is a full example of how to do this via PHP using cURL.
<!DOCTYPE html>
<html>
<head>
<title>Fitment example</title>
</head>
<body>
<?php
// Parameters to send the web service program.
$vars = array(
'DEALER' => '', // Your wpsorders dealer number.
'PASSWORD' => '', // Your wpsorders admin account password.
'FITMENT' => 'HONDA HON8300 2012', // Here you would enter the fitment key. (ie. Make-name Model-number Year)
'OUTPUT' => 'json' // JSON is used in this example.
);
// Make the cURL request.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.wpswebservices.com/version2/wsFITS.pgm");
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$curl_result = curl_exec($ch);
curl_close($ch);
// Decode the JSON string into stdObject.
$result = json_decode($curl_result);
// Print the HTML to set up a table.
echo '<h2>There are ' . $result->response->numFound . ' items that fit a "' . $vars['FITMENT'] . '" vehicle:</h2>' . "\n";
echo '<table border="1">' . "\n";
echo ' <thead>' . "\n";
echo ' <tr>' . "\n";
echo ' <th>prtnmbr</th><th>name</th><th>listprc</th><th>mainimg</th>' . "\n";
echo ' </tr>' . "\n";
echo ' </thead>' . "\n";
echo ' <tbody>' . "\n";
// For each 'docs' property in the response, do this:
foreach ($result->response->docs as $a) {
$image = (property_exists($a, 'mainimg')) ? $a->mainimg : 'image_coming_soon.jpg';
echo ' <tr>' . "\n";
echo ' <td>' . $a->prtnmbr . '</td>' . "\n";
echo ' <td>' . $a->name . '</td>' . "\n";
echo ' <td>$' . $a->listprc . '</td>' . "\n";
echo ' <td><img src="http://www.wpsstatic.com/WPSIMAGES/thumbs/' . $image . '"></td>' . "\n";
echo ' <tr>' . "\n";
}
// Print the closing HTML
echo ' </tbody>' . "\n";
echo '</table>' . "\n";
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment