1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Getting Commission Junction's API to work

Discussion in 'Commission Junction' started by SimonHa, Aug 19, 2009.

  1. MasterG

    MasterG Peon

    Messages:
    252
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #21
    You can use SKUs from newegg and get query back? Could you please share your code or your newegg sku? I do not get any return from api.

    <?xml version="1.0" encoding="UTF-8"?>

    <cj-api><products total-matched="0" records-returned="0" page-number="1"/></cj-api>

    Please help.
     
    Last edited: Sep 10, 2009
    MasterG, Sep 10, 2009 IP
  2. SeoGrr

    SeoGrr Active Member

    Messages:
    116
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #22
    For some reason cj api stopped working for the last two weeks for me and my programmer cannot find a way to make requests.
     
    SeoGrr, Sep 11, 2009 IP
  3. MasterG

    MasterG Peon

    Messages:
    252
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #23
    For just some merchant? I can get request until now.
     
    MasterG, Sep 11, 2009 IP
  4. markowe

    markowe Well-Known Member

    Messages:
    1,136
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    165
    #24
    Hmm, I have been tinkering with the API today actually, and it's working fine... There are a few reasons I got some empty calls though - one was simply that the advertiser I was interested in does not actually make his products available through the API - duhh.... Try changing the advertiser ID, or not specifying one at all, just to see.
     
    markowe, Sep 11, 2009 IP
  5. MasterG

    MasterG Peon

    Messages:
    252
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #25
    I got some empty call from newegg.com, buydigg, beachcamera and more. As I investigate, only sku IS NOT numeric it's problem.

    Do you working fine in newegg.com?
     
    MasterG, Sep 11, 2009 IP
  6. SimonHa

    SimonHa Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #26
    Unfortunately, newegg denied my application so I can't access your api. I don't understand your last post. Are SKUs working for you? if so, why not just use them? sorry I can't actually run code,
     
    SimonHa, Sep 12, 2009 IP
  7. MasterG

    MasterG Peon

    Messages:
    252
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #27
    Ok Can you work on api with sku for newegg? I believe you are success to coding application. So that's why i asked you.
     
    MasterG, Sep 12, 2009 IP
  8. 45n5

    45n5 Peon

    Messages:
    414
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #28
    for those getting the "bool(false)" error, this updated curl code worked for me. use at your own risk ;)

    putt your id's where it says "YOURID"

    
    <?php
    $pagenumber=1;
    $howmany=10;
    $websiteid="YOURID";
    $CJ_ID = "YOURID";
    $url = "https://product-search.api.cj.com/v2/product-search?website-id=$websiteid&advertiser-ids=726692&page-number=$pagenumber&records-per-page=$howmany";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, FAlSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: '.$CJ_ID));
    $curl_results = curl_exec($ch);
    curl_close($ch);
    $returnXML = simplexml_load_string($curl_results);
    var_dump($returnXML);
    ?>
    
    Code (markup):
     
    45n5, Sep 18, 2009 IP
  9. SimonHa

    SimonHa Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #29
    MasterG,

    I am sorry that I can't run your code. Newegg did not approve my application. Since they did not approve my application, I can't access their API and run a search for products that Newegg offers.
     
    SimonHa, Sep 18, 2009 IP
  10. MasterG

    MasterG Peon

    Messages:
    252
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #30
    can you try on buydigg.com or abeofmaine? these 2 merchants I strill have problem.
     
    MasterG, Sep 24, 2009 IP
  11. markowe

    markowe Well-Known Member

    Messages:
    1,136
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    165
    #31
    You don't have to have a relationship with an advertiser to see their product listings. I can get a listing from the API for NewEgg very easily, with this simple code (I just can't use the affiliate link, or it will show as an invalid click in my report) - just upload it as, say, GetCJ.php:

    <?php
    $keywords = $_GET['s']; // this is just so you can add a search keyword to your URL
    $devKey = 'YOUR_CJ_DEVELOPER_KEY';
    $siteKey = '1234567'; // Your site key
    $advertiserIds = '1807847'; // NewEgg advertiser ID
    $client = new SoapClient ("https://product.api.cj.com/wsdl/version2/productSearchServiceV2.wsdl");
    $results = $client->search(array ('developerKey' => $devKey, 'websiteId' => $siteKey, 'keywords' => $keywords, 'advertiserIds' => $advertiserIds, 'UPC' => $UPC));
    print "<pre>";
    print_r($results);
    print "</pre>";
    ?>
    PHP:
    And just call the script: http://www.mysite.com/GetCJ.php?s=netbook

    The "s" parameter is optional, but you can use it to specify a keyword. You could also add a line:

    $UPC=$_GET['upc'];
    PHP:
    and you could search for a specific product code (UPC), but NewEgg doesn't list these for some reason, only their own SKU product code so no use here.

    Unfortunately, compared to eBay or Amazon APIs, CJ's is VERY limited - this is about all you CAN do with it! But this SHOULD work with NewEgg fine - I have just tested it.

    P.S. I think you need PHP5 for the above code to work (SOAP support not available in earlier versions) - but you should really be using PHP5 by now anyway.
     
    markowe, Sep 24, 2009 IP
  12. MasterG

    MasterG Peon

    Messages:
    252
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #32
    Thank you so much. I used to try on soap but sometime is slower than REST. Could you please try on REST format?

    Please help us.
     
    MasterG, Sep 24, 2009 IP
  13. markowe

    markowe Well-Known Member

    Messages:
    1,136
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    165
    #33
    Hi - oh yes, REST... Sorry, I haven't actually looked into the REST API method so I don't know exactly how you program for that. You have to send the authorisation code in the header, which I would have to write some code for and don't have time to figure it out now...
     
    markowe, Sep 24, 2009 IP
  14. MasterG

    MasterG Peon

    Messages:
    252
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #34
    Thank you. If you have free time, please help. I can send authorized to cj rest and get response just some merchant such as buy.com, macmall.com but newegg, buydigg ,etc... i got not record found. I still confuse about cj rest.
     
    MasterG, Sep 24, 2009 IP
  15. SimonHa

    SimonHa Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #35
    Here is what I got:

    This script uses REST. As you can see, the advertiser id is for Newegg. To search by SKU, I added "manufacturer-sku=" to the request. Now the part that I do not understand is why this code doesn't work for manufacturer SKUs with letters in them.

    for example
    SKUs: N-7369 and G5611 don't work

    SKUs: 65201 and 047875953437 work fine. I am going to ask around at other forums and see if there is some reason that SKUs with letters don't work, and SKus with only numbers do. If you figure this out, pleas post. Sorry it took so long for me to reply,
    Simon

    <?php
    $url='https://product-search.api.cj.com/v2/product-search?website-id=XXXXXXXX&advertiser-ids=1807847&manufacturer-sku=29955-01&records-per-page=1000&sort-by=price&serviceable-area=US'; 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
    $CJ_KEY ='XXXXXXXXXXXX'; 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_POST, FALSE); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, 
    array('Authorization: ' . $CJ_KEY)); 
    $curl_results = curl_exec($ch);   
    $info = simplexml_load_string($curl_results); 
    print_r($info); 
    ?>
    PHP:
     
    SimonHa, Sep 24, 2009 IP
  16. MasterG

    MasterG Peon

    Messages:
    252
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #36
    I still have same issue like you.
     
    MasterG, Sep 24, 2009 IP
  17. MasterG

    MasterG Peon

    Messages:
    252
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #37
    Any progress? I still have problem with sku. I also ask to CJ support but they answer very very slow.
     
    MasterG, Oct 12, 2009 IP
  18. MasterG

    MasterG Peon

    Messages:
    252
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #38
    Wow. Still no feedback from anyone about cj issue. I have time to testing cj catalog search. I use the script to search product from cj and found something different.

    for example. i use canon sx200 in keyword search and i got many merchant from cj as i joined. Then I write upc, manufacturer-sku and advertiser-sku out for checking and I got something.

    Some of merchants has upc but do not have manu-sku or advertiser-sku? Some of merchants have the same manu-sku but different upc and adversiter-sku? Some of merchants have all informations.

    Then I also try to split testing of 3 kinds of code (upc,manu sku, advertiser sku) by 3 script.

    The result is amazing..... some merchants accept only upc for api search, some merchants accept only upc and advertiser sku, some merchants accept only manu sku and upc, some merchants do not accept any kind of code.

    I have issued to CJ support their engineer are working on that but I think it's might be on merchant to allow api to grab data out. I will working on my site is better than waiting for them.

    I hope I can finish as soon as possible. I try to test some product and it's take time to connect so I need to change more than 12 hrs for user browse faster.

    Master.
     
    MasterG, Oct 20, 2009 IP
  19. SimonHa

    SimonHa Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #39
    MasterG,

    I haven't forgotten about this thread. I noticed inconsistances in CJ as well. For example, sometimes if I make a REST request using the ISBN, sometimes a CJ vender will show that he doesn't have it. But when I go to the particular vender's website, he has many in stock. I think maybe its the vendor's fault not CJ. I don't know though.
     
    SimonHa, Oct 20, 2009 IP
  20. ChuckMcB

    ChuckMcB Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #40
    (tips hat to markowe)

    I'm battling with CJ API as well. Couple of observations:

    1) vender's data are inconsistance for ISBNs, sometimes they store it as upc sometimes as isbn, I've ended up doing a search for both.
    2) the fact that minus signs are used in the xml tags breaks simplexml. For example:

    	foreach ($xml->products->product as $node) {
    		echo $node->advertiser-name;
    	}
    Code (markup):
    returns 0
    
    where as 	foreach ($xml->products->product as $node) {
    		echo $node->price;
    	}
    Code (markup):
    returns 19.99

    Anyone got any bright ideas how to fix 2?

    (hmm...wonder if I can just so a str_replace "-" for "")
     
    ChuckMcB, Nov 24, 2009 IP