2014-03-19 40 views
1

我想將SMS集成到我的API並嘗試傳遞URL中的變量,但它說錯誤,找不到數字。如何通過file_get_contents傳遞URL中的變量值

請幫

$sender = "9999708993"; 
$reply_message = "This is an auto generated message"; 

echo $sender; 
echo $reply_message; 

$lines = file_get_contents('http://sms2.oxyzen.in/httpapi/sendsms.php?loginid=myid&password=mypassword&senderid=mysenderid&message=$reply_message&number=$sender'); 

echo "<pre>$lines</pre>"; 

回答

4

使用雙引號而不是單引號,如果你想要把變量:

$lines = file_get_contents("http://sms2.oxyzen.in/httpapi/sendsms.php?loginid=myid&password=mypassword&senderid=mysenderid&message=$reply_message&number=$sender"); 

請試試這個:

$sender = "9999708993"; 
$reply_message = urlencode("This is an auto generated message"); 


//I think you need to change these 
$loginid='myid'; 
$mypassword='mypassword'; 
$mysenderid='mysenderid'; 

$uri = "http://sms2.oxyzen.in/httpapi/sendsms.php?loginid=$myid&password=$mypassword&senderid=$mysenderid&message=$reply_message&number=$sender"; 
var_dump($uri); 
$lines=file_get_contents($uri); 
var_dump($lines); 
+0

我有也嘗試過。我收到了同樣的消息,ERROR |沒有找到號碼 – user3438532

+0

請參閱此問題的其他內容,請嘗試 – edmondscommerce

+0

我已嘗試添加代碼以及我已收到此....字符串(277)「http://sms2.oxyzen.in/httpapi/sendsms.php &number = 9999708993「string(23)」ERROR | No Number Found「 ERROR | ERROR | ERROR | ERROR | ERROR | ERROR | ERROR | ERROR | ERROR |沒有找到號碼 – user3438532