0

I have a problem when I want to send a GET request with php curl or file_get_contents function !!! I think this problem is for my URL !!! please help me ... my code (file_get_contents function):

$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);

my code (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
Mohammad Ilbeygi
  • 191
  • 3
  • 11
  • 3
    Possible duplicate of [PHP cURL GET request and request's body](https://stackoverflow.com/questions/17230246/php-curl-get-request-and-requests-body) – RAUSHAN KUMAR Oct 18 '17 at 09:59

1 Answers1

0

This URL redirects to another URL.
You need to add: curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

Misunderstood
  • 5,534
  • 1
  • 18
  • 25