ChicagoDude
ChicagoDude

Reputation: 601

PHP and CURL query and how to retrieve response in variable

i am trying to use the CURL to get a respose back in a PHP web app..

curl -d "qid=QID&api_key=API_KEY&api_sig=API_SIG&time_stamp=TIMESTAMP" \
 http://api.1.com/v1.2/result/

I have all the variables as known - but how do i form and execute above in PHP to get the result into a $RESULTRESPONSE variable? I am expecting a response in xml format back.

I know of curl_init, curl_exec, but not sure how curl_setopt comes into play for this. Thanks.

Upvotes: 0

Views: 9608

Answers (1)

OptimusCrime
OptimusCrime

Reputation: 14863

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'YOU_URL_GOES_HERE');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);
$YOUR_RETURN_EDCONTENT_GOES_HERE = curl_exec($ch);
curl_close($ch);

Not 100% sure what you mean, but this will store your information from the curl in the $YOUR_RETURN_EDCONTENT_GOES_HERE variable.

Upvotes: 9

Related Questions