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.

Revisions

  1. AustinMaddox revised this gist Mar 5, 2014. 1 changed file with 28 additions and 24 deletions.
    52 changes: 28 additions & 24 deletions fitment_part_number_request_service_example.php
    Original file line number Diff line number Diff line change
    @@ -1,23 +1,27 @@
    <?php error_reporting(E_ALL | E_STRICT); ?>
    <!DOCTYPE html>
    <html>
    <head>
    <title>Fitment example</title>
    </head>
    <body>
    <?php
    error_reporting(E_ALL | E_STRICT);
    // Parameters to send the web service program.
    // Example: http://www.example.com/fitment_part_number_request_service_example.php?DEALER=###&PASSWORD=###&FITMENT=HONDA HON8300 2012&OUTPUT=json
    $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.
    'DEALER' => FILTER_SANITIZE_ENCODED, // Your wpsorders dealer number.
    'PASSWORD' => FILTER_SANITIZE_ENCODED, // Your wpsorders admin account password.
    'FITMENT' => FILTER_SANITIZE_STRING, // The three part fitment key obtained from the fitment structure dump. (ie. Make-name Model-number Year)
    'OUTPUT' => FILTER_SANITIZE_ENCODED // 'json' is used in this example.
    );

    // Gets external variables and optionally filters them.
    $filtered_vars = filter_input_array(INPUT_GET, $vars);

    // 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_POSTFIELDS, $filtered_vars);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    $curl_result = curl_exec($ch);
    @@ -28,35 +32,35 @@

    // If the result is not valid JSON.
    if ($result_json === NULL) {
    echo $curl_result . "<br>\n";
    echo $curl_result . '<br>' . PHP_EOL;
    die('The result of the cURL could not decoded with json_decode().');
    }

    // Print the HTML to set up a table.
    echo '<h2>There are ' . $result_json->response->numFound . ' items that fit a "' . $vars['FITMENT'] . '" vehicle:</h2>' . "\n";
    echo '<h2>There are ' . $result_json->response->numFound . ' items that fit a "' . $filtered_vars['FITMENT'] . '" vehicle:</h2>' . PHP_EOL;

    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";
    echo '<table border="1">' . PHP_EOL;
    echo ' <thead>' . PHP_EOL;
    echo ' <tr>' . PHP_EOL;
    echo ' <th>prtnmbr</th><th>name</th><th>listprc</th><th>mainimg</th>' . PHP_EOL;
    echo ' </tr>' . PHP_EOL;
    echo ' </thead>' . PHP_EOL;
    echo ' <tbody>' . PHP_EOL;

    // For each 'docs' property in the response, do this:
    foreach ($result_json->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";
    echo ' <tr>' . PHP_EOL;
    echo ' <td>' . $a->prtnmbr . '</td>' . PHP_EOL;
    echo ' <td>' . $a->name . '</td>' . PHP_EOL;
    echo ' <td>$' . $a->listprc . '</td>' . PHP_EOL;
    echo ' <td><img src="http://www.wpsstatic.com/WPSIMAGES/thumbs/' . $image . '"></td>' . PHP_EOL;
    echo ' <tr>' . PHP_EOL;
    }

    // Print the closing HTML
    echo ' </tbody>' . "\n";
    echo '</table>' . "\n";
    // Print the closing HTML closing tags.
    echo ' </tbody>' . PHP_EOL;
    echo '</table>' . PHP_EOL;
    ?>
    </body>
    </html>
  2. Austin revised this gist Aug 29, 2013. 2 changed files with 62 additions and 55 deletions.
    55 changes: 0 additions & 55 deletions fitment_part_number_request service_example.php
    Original file line number Diff line number Diff line change
    @@ -1,55 +0,0 @@
    <!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>
    62 changes: 62 additions & 0 deletions fitment_part_number_request_service_example.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,62 @@
    <!DOCTYPE html>
    <html>
    <head>
    <title>Fitment example</title>
    </head>
    <body>
    <?php
    error_reporting(E_ALL | E_STRICT);
    // 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, TRUE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    $curl_result = curl_exec($ch);
    curl_close($ch);

    // Decode the JSON string into stdObject.
    $result_json = json_decode($curl_result);

    // If the result is not valid JSON.
    if ($result_json === NULL) {
    echo $curl_result . "<br>\n";
    die('The result of the cURL could not decoded with json_decode().');
    }

    // Print the HTML to set up a table.
    echo '<h2>There are ' . $result_json->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_json->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>
  3. Austin renamed this gist Aug 28, 2013. 1 changed file with 0 additions and 0 deletions.
  4. Austin created this gist Aug 28, 2013.
    55 changes: 55 additions & 0 deletions Fitment part number request service
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,55 @@
    <!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>