PHP和CURL查询以及如何检索变量中的响应 [英] PHP and CURL query and how to retrieve response in variable
本文介绍了PHP和CURL查询以及如何检索变量中的响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用CURL在PHP Web应用程序中重新放置。
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/
我具有所有已知的变量-但是如何在PHP中形成并执行上述操作,以将结果转换为$ RESULTRESPONSE变量?我期望以xml格式返回。
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.
我知道curl_init,curl_exec,但不确定curl_setopt如何发挥作用。
I know of curl_init, curl_exec, but not sure how curl_setopt comes into play for this. Thanks.
推荐答案
$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);
不是100%知道您的意思,但这会将您的信息存储在 $ YOUR_RETURN_EDCONTENT_GOES_HERE
变量。
Not 100% sure what you mean, but this will store your information from the curl in the $YOUR_RETURN_EDCONTENT_GOES_HERE
variable.
这篇关于PHP和CURL查询以及如何检索变量中的响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文