2017-10-18 2 views
0

PHP curl 또는 file_get_contents 함수로 GET 요청을 보내려 할 때 문제가 있습니다 !!! 이 문제는 내 URL에 맞는 것 같습니다. 좀 도와주세요 ... 내 코드 (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은 다른 URL로 리디렉션합니다.
당신은 추가해야합니다 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

관련 문제