Results 1 to 1 of 1

 

Thread: CJ Product API php code (uses SOAP)

  1. #1
    scriptmonkey's Avatar
    Oranges & Lemons

    Status
    Offline
    Join Date
    Jan 2009
    Location
    Worthing
    Posts
    1,607
    Thanks
    112
    Thanked 253 Times in 192 Posts


    Another bit of code, this time, the CJ API, you'll need a developer key from CJ:

    PHP Code:
    <?php
            $developerKey 
    "YOUR-DEVELOPER-KEY";
            
    $websiteId "YOUR-SITEID";
            
        try {
            
    $client = new SoapClient("https://product.api.cj.com/wsdl/version2/productSearchServiceV2.wsdl", array('trace'=> true));
            
    $results $client->search(array("developerKey" => $developerKey,
                                                
    "websiteId" => $websiteId,
                                                
    "advertiserIds" => '',
                                                
    "keywords" => 'washing+machine',
                                                
    "lowPrice" => '5',
                                                
    "highPrice" => '1000',
                                                   
    "currency" => 'GBP',
                                                   
    "sortBy" => 'price',
                                                 
    "sortOrder" => 'asc',
                                                
    "startAt" => 1,
                                                
    "maxResults" => 10));
                                                
        foreach(
    $results->out->products->Product as $details
            {
                
    $adId $details->adId;
                
    $advertiserId $details->advertiserId;
                
    $advertiserName $details->advertiserName;
                
    $buyUrl $details->buyUrl;
                
    $catalogId $details->catalogId;
                
    $currency $details->currency;
                
    $description $details->description;
                
    $imageUrl $details->imageUrl;
                
    $inStock $details->inStock;
                
    $isbn $details->isbn;
                
    $manufacturerName $details->manufacturerName;
                
    $manufacturerSku $details->manufacturerSku;
                
    $name $details->name;
                
    $price $details->price;
                
    $retailPrice $details->retailPrice;
                
    $salePrice $details->salePrice;
                
    $sku $details->sku;
                
    $upc $details->upc;
            
            echo 
    '<a href="'.$buyUrl.'" target="_blank"><img style="float: left; margin: 10px; border: 1px solid #e4e4e4;" src="'.$imageUrl.'" alt="'.$name.'" width="200"  /></a><strong>'.$name.'</strong> '.$description.'<br /><br />Brand: '.$manufacturerName.'<br /><br /><strong>'.$manufacturerName.' '.$name.'</strong><br /><br /><strong>&pound;'.$price.'</strong><br /><a href="'.$buyUrl.'" target="_blank"><br /><img src="http://www.emmanie.co.uk/clickhere.png" alt="'.$name.'" border="0" /></a><hr style="clear:both;"  />';
            }

            } catch (
    Exception $e){
                echo 
    "There was an error with your request or the service is unavailable.\n";
                
    print_r ($e);
            }
    ?>
    I've added ALL the returned fields as variables, in case you want to use them in your code.

    This is what it should look like Washing Machines via CJ API
    The trouble with the rat race is that even if you win you're still a rat.
    Time passes. Listen. Time passes. Dylan Thomas
    Ebay Alerts to your inbox

  2. The Following User Says Thank You to scriptmonkey For This Useful Post:

    stuartqwh (02-02-11)



Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2