2017-04-26 19 views
0

file_get_contents(http://smshorizon.co.in/api/sendsms.php?user=***&apikey=******&mobile=*****&message=Hello World&senderid=xxyy&type=txt)file_get_contents()函数的问题与我的短信API intrigation

在这里,当我使用一个消息,这个空间API的短信显示“Hello World”,那么它返回HTTP/1.1 400 Bad Request。但是,当我删除空间,而是我写HelloWorld它工作正常。

问题是什么?

+0

您是否尝试过使用url编码? http://php.net/manual/en/function.urlencode.php –

+0

是的我已经通过使用str_replace与“%20”的空间解决了这个问题, –

回答

0

为什么它的发生(问题):

网址是越来越吐尽消息之间因为空间,它会考虑空间之前,只有部分。

解决方案:

您可以使用PHP内置功能进行urlencode();

Input : urlencode('Hello World'); 
Output : urlencode('Hello%20World');