2017-10-18 3 views
0

J'ai un problème quand je veux envoyer une requête GET avec php curl ou la fonction file_get_contents !!! Je pense que ce problème est pour mon URL !!! s'il vous plaît aidez-moi ... mon code (fonction file_get_contents):Comment envoyer une requête GET avec 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; 

echo file_get_contents($SMSurl); 

mon code (curl 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

double possible de [PHP cURL requête GET et le corps de la demande] (https://stackoverflow.com/questions/17230246/php-curl-get-request-and-requests-body) –

Répondre

0

Cette URL redirige vers une autre URL.
Vous devez ajouter: curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);