2017-10-18 223 views
0

我想用PHP curl或file_get_contents函數發送GET請求時遇到問題!!! 我認爲這個問題是爲我的網址! 請幫我...我 碼(的file_get_contents功能):如何用PHP curl發送GET請求

$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的捲曲):

$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 
+3

的可能的複製[PHP捲曲GET請求,請求體(https://stackoverflow.com/questions/17230246/php-curl-get-request-and-requests-body) –

回答

0

這個URL重定向到另一個網址。
您需要添加:curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);