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. markowe

    markowe Well-Known Member

    Messages:
    1,135
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    115
    #41
    Tips hat back. I am not too hot with XML but seems funny that minus should break it. Maybe replacing it with another character would be the quickest "dirtiest" solution but I guess it would be good to find a cleaner solution in the long run...

    As for all those inconsistencies in CJ data, oh man, that data is all over the place. If you are aggregating data from several different advertisers, you never QUITE know if the fields are all going to be the same. I think it's even worse with datafeeds - I am messing with these at the moment and it's all over the place, such that I will have to write code to "map" fields to their proper labels, it will just be chaos otherwise...SEMrush
     
    markowe, Nov 25, 2009 IP
    SEMrush
  2. ChuckMcB

    ChuckMcB Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #42
    Yup, a minus sign in the element name causes PHP5's simplexml not to return valid/correct output. (it returns '0' rather then the value)

    Since I'm really only interested in outputting a couple of the elements I did a str_replace on these element names and was able to get their value correctly (you can't do a global replace as that would break encoding value and any URLs that use minus signs...sigh)

    As I'm running a niche price comparison site I'm just interested in ISBN/EAN but I've noticed that some force you to search by ISBN, other by UPC..handy.
     
    ChuckMcB, Nov 25, 2009 IP
  3. QiSoftware

    QiSoftware Well-Known Member

    Messages:
    787
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    128
    #43
    I have done a lot with CJ's API but have never been able to get the ISBN field to work. I think the problem is-- the ISBN field is not maintained by CJ.

    Q...
     
    QiSoftware, Nov 25, 2009 IP
  4. ChuckMcB

    ChuckMcB Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #44
    The ISBN's working for me at the moment (I search for ISBN using ISBN13 and UPC also using ISBN13 to get all results). I'm getting results from Argos and PriceMinister (BBC Shop stopped working today sometime) but as I say I'm rather niche (and targeting the UK market).

    Datafeeds/APIs are always maintained by the advertiser, who can't see the value in providing good data them unless there are good systems that can use them...which affilates will not spend time building until the data is good....catch22 anyone?
     
    ChuckMcB, Nov 25, 2009 IP
  5. markowe

    markowe Well-Known Member

    Messages:
    1,135
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    115
    #45
    Ah, right... yeah, that would explain it. Though if chaos reigns in their datafeeds, that must be what their internal product database looks like too... One top advertiser I looked at that sells event tickets actually doesn't provide a separate field with the date of the event! You would have to regexp it out of a field that has it in, concatenated with some other useless data. I mean, correct me if I am wrong, but the event date would be quite useful to have available..?

    So I am trying to write a script for use with those feeds that is as scalable as possible, so I can reuse the code with the wide and colourful variety of CJ datafeeds that are out there. But it's so much work... Like you say, Catch 22, but there's always some mug with more time than sense :)
     
    markowe, Nov 25, 2009 IP
  6. SimonHa

    SimonHa Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #46
    This is how I got around the problem:

    $AdvertiserName = "advertiser-name";
    foreach($info->products->product as $name)
    {
    echo "<h3>". $name->$AdvertiserName. "</h3>";
    };
    PHP:
    hope it helps
     
    SimonHa, Nov 30, 2009 IP
  7. SimonHa

    SimonHa Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #47
    This is what I did and it works so far:

    $AdvertiserName = "advertiser-name";
    foreach($info->products->product as $name)
    {
    echo "<h3>". $name->$AdvertiserName. "</h3>";
    };
    PHP:
    hope this helps
     
    SimonHa, Nov 30, 2009 IP
  8. ChuckMcB

    ChuckMcB Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #48
    Yes, that probably be more efficient and would scale better than my chosen solution:

    	$xml = str_replace("advertiser-name","advertiser_name",$curl_results);
    	$xml = str_replace("buy-url","buy_url",$xml);
    Code (markup):
     
    ChuckMcB, Dec 1, 2009 IP
  9. vitamind

    vitamind Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #49
    I'm stumped by the SKU search for an SKU with letters in it returning zero results. Someone mentioned that earlier. This seems to be a problem with the API itself, rather than the advertisers. Anyone have a good workaround for that?
     
    vitamind, Jan 23, 2010 IP
  10. mxyzplk

    mxyzplk Active Member

    Messages:
    792
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    85
    #50
    I'm struggling with CJ SOAP API, this is really challenges me, but Im still stuck with the array, I don't what is the difference yet between print_r and echo, and everytime I try foreach() it said invalid arguments...
    I hope I could finish this project in weeks..
     
    mxyzplk, Feb 15, 2010 IP
  11. mxyzplk

    mxyzplk Active Member

    Messages:
    792
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    85
    #51
    
    stdClass Object
    (
        [out] => stdClass Object
            (
                [count] => 1
                [offset] => 0
                [products] => stdClass Object
                    (
                        [Product] => stdClass Object
                            (
                                [adId] => 10387773
                                [advertiserId] => 1566996
                                [advertiserName] => Buy.com USA and Buy.com CA
                                [buyUrl] => http://www.kqzyfj.com/click-3515477-10387773?url=http%3A%2F%2Fwww.buy.com%2Fprod%2Fdell%2Fq%2Floc%2F106%2F202168850.html&cjsku=202168850
                                [catalogId] => cjo:986
                                [currency] => USD
                                [description] => Dell
                                [imageUrl] => http://ak.buy.com/db_assets/prod_images/850/202168850.jpg
                                [inStock] => 
                                [isbn] => 9781420897258
                                [manufacturerName] => Authorhouse
                                [manufacturerSku] => 9781420897258
                                [name] => Dell
                                [price] => 16.99
                                [retailPrice] => 17.99
                                [salePrice] => 0
                                [sku] => 202168850
                                [upc] => 09781420897258
                            )
    
                    )
    
                [totalResults] => 94713
            )
    
    )
    
    Code (markup):
    here is my result with api cj soap sample code, I don't know what to do next, foreach() doesn't work, I really don't have any good idea that works...
     
    mxyzplk, Feb 15, 2010 IP
  12. markowe

    markowe Well-Known Member

    Messages:
    1,135
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    115
    #52
    Try this:

    foreach ($data->out->products->Product as $Product)
    
    {
    print_r ($Product);
    }
    PHP:
    Where $data is your SOAP object. This just creates an object for each product, called $Product (the print_r just prints each one out so you can see).

    Works on one of my sites. Then you get elements like this (for each element in the foreach loop, i.e. this needs to be inside the loop):

    $name = (string)$Product->name;
    $advertiserName = (string)$Product->advertiserName;
    $manufacturerName = (string)$Product->manufacturerName;
    
    //... etc.
    
    PHP:
    Obviously you need to do something more than just assign the variables else they will get overwritten with each recursion. But try just echoing $name etc. just to see.

    Oh yes, typecasting... Can't remember why now (it was a while back I wrote that) but for some reason you need to cast the results as a (string), else they remain as an object, something like that. Hope this helps.
     
    markowe, Feb 18, 2010 IP
  13. ChuckMcB

    ChuckMcB Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #53
    Seems that the BBC Shop needs us affiliates again now that Christmas has passed >;-) as CJ is now returning items from them in the last couple of hours.

    I'm sure it was just a simple mistake by CJ/BBC Shop....hmmm...
     
    ChuckMcB, Mar 12, 2010 IP
  14. BigMarv

    BigMarv Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #54
    Tank you I agree
     
    BigMarv, Mar 12, 2010 IP
  15. FunkyFresh

    FunkyFresh Peon

    Messages:
    499
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #55
    I read the whole thread but I still cant figure out how to use the REST api. can anyone provide a sample for php?
    thanks
     
    FunkyFresh, Oct 1, 2011 IP
  16. vikistunner

    vikistunner Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #56
    Hi

    When i used your code .I got the the following error message. What can be the problem? I changed my developer key also in the $CJ_KEY variable.

    object(SimpleXMLElement)#1 (1) { ["error-message"]=> string(273) "Not Authenticated: developer key here"}

    Thanks in advance..
     
    vikistunner, Dec 18, 2012 IP
  17. vikistunner

    vikistunner Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #57
    Hi

    When i used your code .I got the the following error message. What can be the problem? I changed my developer key also in the $CJ_KEY variable.

    object(SimpleXMLElement)#1 (1) { ["error-message"]=> string(273) "Not Authenticated: developer key here"}

    Thanks in advance..
     
    vikistunner, Dec 18, 2012 IP
  18. an71qu3

    an71qu3 Greenhorn

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #58
    I have the same problem . Can anyone help us ? Thank you.
     
    an71qu3, Dec 18, 2012 IP
  19. Evermarker Jewelry

    Evermarker Jewelry Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #59
    :)
     
    Evermarker Jewelry, Aug 31, 2016 IP
  20. sudhansu sekhar

    sudhansu sekhar Greenhorn

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #60
     
    sudhansu sekhar, Apr 15, 2017 IP