开发者

Why is my string containing a URL breaking my script?

Using twitterauth to try to post status updates. This is my code (which returns a 403 error from twitter when I try to post it):

$fact = "This is a status update. http://onth.is/iss" ;
$parameters = array('status'开发者_如何学JAVA => $fact);

However, if I do this:

$parameters = array('status' => "This is a status update. http://onth.is/iss");

It post perfectly fine. I know it has something to do wit the URL, because if I remove it from the first code it works.

Any tips? Thanks in advance!


If you are referring to the twitteroath library then I don't see anything wrong with your code. However, you can speed things up a little bit by doing:

$parameters["status"] = "This is a status update. http://onth.is/iss";


The two statements are identical, except that the latter will create a syntax error :)

My guess would be that you need to urlencode() the string before sending it to Twitter, but not knowing the library you are using, I can't say for sure.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜