Forum Moderators: coopster

Message Too Old, No Replies

using cUrl to get information

         

eatspinach

4:27 pm on Mar 12, 2010 (gmt 0)

10+ Year Member



Hi

I need a little understanding cUrl. I am able to post xml data to a url to create new campaigns and its working fine. Now i need to send a chunk of xml to the same url with the campaign id that i just created "85" and get the information back, does curl work this way?

my code so far is this.. but it does nothing


$xmlData = "<xml><command name="get"/><Id>85</Id></xml>";

$curlObject = curl_init();
//Sets an option on the given cURL session handle
curl_setopt($curlObject, CURLOPT_URL, "http://myurl.com");
//do not get the Header
curl_setopt ($curlObject, CURLOPT_HEADER, false);
// get the response as a string from curl_exec(), rather than echoing it
curl_setopt ($curlObject, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($curlObject, CURLOPT_POST, true);
curl_setopt ($curlObject, CURLOPT_POSTFIELDS, "$xmlData");
$response = curl_exec($curlObject);

print $response;

curl_close ($curlObject);

eatspinach

4:37 pm on Mar 12, 2010 (gmt 0)

10+ Year Member



never mind, i figured it out

$ch = curl_init();
/**
* Set the URL of the page or file to download.
*/
curl_setopt($ch, CURLOPT_URL,
'www.myurl.com');
/**
* Ask cURL to return the contents in a variable
* instead of simply echoing them to the browser.
*/
curl_setopt ($ch, CURLOPT_POSTFIELDS, "$xmlData");


curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
/**
* Execute the cURL session
*/
$contents = curl_exec ($ch);
/**
* Close cURL session
*/
curl_close ($ch);

print $contents;

Anyango

6:03 pm on Mar 12, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So your cURL issue got fixed on server ? It would be nice if you post your solution to that problem, on that thread where we talked about it. So if some other member has the same problem they can refer to your thread