Jump to content

REST Webservices CURL extension help


WWW_9hub_Net

Recommended Posts

Hi,

 

I have used the following script to consume REST webservices  provided by Commission Junction. I'm able to get the response but the response is not in xml format.

 

<?php$targeturl="https://support-services.api.cj.com/v2/countries";$CJ_DevKey= "xxxxxxxxx";// return xml feed from CJ$ch = curl_init($targeturl);curl_setopt($ch, CURLOPT_POST, FAlSE);curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: '.$CJ_DevKey));curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);$response = curl_exec($ch);curl_close($ch);echo $response; // will print in browser all country codes in an xml format/*ADD YOUR OWN CODE HERE TO DO WHAT YOU WANT WITH THE RESPONSE.  MAYBE SAVE RESULTS TO A FILE OR THE PARSE THE RESULTS INTO A DATABASE?*/?>

 

I'm just confused. Isn't that the response when using REST webservices is always in xml format. Please correct me if I'm wrong.

 

Would someone please have a look at this script and suggest me what I need to do in order to get the response in xml ? I want to save the response in xml file and then process it later.

 

please see my current sample output here. www(dot)uedeals(dot)com/cj/cj3.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.