繁体   English   中英

如何使用php curl发送GET请求

[英]How to send GET request with php curl

当我想使用php curl或file_get_contents函数发送GET请求时遇到问题! 我认为这个问题是我的网址! 请帮助我...我的代码(file_get_contents函数):

$SMStext = "text";
$SMSmobile = 'phonenumber';
$SMSurl = "http://api.payamak-panel.com/post/sendsms.ashx?username=username&password=pass&from=smsnumber&to=";
$SMSurl .= $SMSmobile;
$SMSurl .= '&text=';
$SMSurl .= $SMStext;

echo file_get_contents($SMSurl);

我的代码(php curl):

$SMStext = "text";
$SMSmobile = 'phonenumber';
$SMSurl = "http://api.payamak-panel.com/post/sendsms.ashx?username=username&password=pass&from=smsnumber&to=";
$SMSurl .= $SMSmobile;
$SMSurl .= '&text=';
$SMSurl .= $SMStext;
$ch = curl_init();  

curl_setopt($ch,CURLOPT_URL,$SMSurl);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
//  curl_setopt($ch,CURLOPT_HEADER, false); 

$output=curl_exec($ch);

curl_close($ch);
echo $output

该URL重定向到另一个URL。
您需要添加: curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM