Results 1 to 4 of 4
  1. #1
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Linkshare Web Service Response Issue With REST
    I am using the REST link to call getMerchByName function, but I can't seem to iterate through the returned objects. When I do a print_r on the response I get back, I see all of the data I am looking for. It appears that each merchant data is returned within a <ns1:return></ns1:return> tags.

    I am trying to iterate through all of the returned xml objects/tags, but can't seem to get the syntax right. Not sure what to do after SimpleXmlElement in order to read each chunk of returned data or maybe I shouldn't be using SimpleXmlElement at all.

    Here is my code....

    Code:
    $session = curl_init($request); 
    curl_setopt($session, CURLOPT_HEADER, false); 
    curl_setopt($session, CURLOPT_RETURNTRANSFER, true); 
    $response = curl_exec($session); 
    curl_close($session);  
    
    if(!$response) {      
    die("Request to Linkshare Web  Service failed and no response was returned.");   
    }    
    
    $xml = new SimpleXmlElement($response);

    If you put the URL into Firefox, the data returned looks something like this....

    <ns1:getMerchByNameResponse>

    <ns1:return>
    <ns1:applicationStatus>Approved</ns1:applicationStatus>
    <ns1:categories>10 129 247 155 125 18 9 128 </ns1:categories>
    <ns1:mid>122</ns1:mid>
    <ns1:name>Avon</ns1:name>

    <ns1ffer>
    <ns1:alsoName>439.1</ns1:alsoName>
    <ns1:commissionTerms>sale : 0-null 6%</ns1:commissionTerms>
    <ns1fferId>180347</ns1fferId>
    <ns1fferName>Baseline - 6%</ns1fferName>
    </ns1ffer>
    </ns1:return>

    <ns1:return>
    <ns1:applicationStatus>Approved</ns1:applicationStatus>
    <ns1:categories>154 7 125 18 11 9 19 133 158 120 </ns1:categories>
    <ns1:mid>147</ns1:mid>
    <ns1:name>OmahaSteaks.com, Inc.</ns1:name>

    <ns1ffer>
    <ns1:alsoName>236.5</ns1:alsoName>
    <ns1:commissionTerms>sale : 0-null 7%</ns1:commissionTerms>
    <ns1fferId>7537</ns1fferId>
    <ns1fferName>7% Baseline Offer</ns1fferName>
    </ns1ffer>
    </ns1:return>
    </ns1:getMerchByNameResponse>

  2. #2
    Comfortably Numb John Powell's Avatar
    Join Date
    October 17th, 2005
    Location
    Bayou Country, LA
    Posts
    3,432
    You want me to pm you my short script that does that?


  3. #3
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Quote Originally Posted by John Powell
    You want me to pm you my short script that does that?
    That would be very kind of you John.

  4. #4
    Comfortably Numb John Powell's Avatar
    Join Date
    October 17th, 2005
    Location
    Bayou Country, LA
    Posts
    3,432
    PM sent.


  5. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Web Services - Link Search Service (REST) - Exporting to XML/CSV
    By ddzc in forum Commission Junction - CJ
    Replies: 0
    Last Post: January 4th, 2012, 03:31 PM
  2. Link Search Service (REST)
    By Georgie Peri in forum Commission Junction - CJ
    Replies: 1
    Last Post: December 17th, 2009, 11:19 PM
  3. PJ Web Services or REST links
    By CrazyHunter in forum eBay Partner Network
    Replies: 0
    Last Post: January 7th, 2009, 02:58 AM

Posting Permissions

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