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...
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.
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...
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?
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
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
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
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):
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?
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..
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...
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.
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...
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
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..
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..