【问题标题】:How to send GET request with php curl如何使用 php curl 发送 GET 请求
【发布时间】:2018-03-30 04:04:13
【问题描述】:

当我想使用 php curl 或 file_get_contents 函数发送 GET 请求时遇到问题!!! 我认为这个问题出在我的 URL 上!!! 请帮我 ... 我的代码(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

【问题讨论】:

标签: php curl get-request


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-22
    • 1970-01-01
    • 2013-12-09
    • 1970-01-01
    • 2010-10-31
    • 1970-01-01
    相关资源
    最近更新 更多