tags:

views:

38

answers:

2

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' => $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!

A: 

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.

Pekka
+1  A: 

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";
jsumners
Thanks. I changed my one line to what you suggested. It looks like it's working better. I'm wondering if I just wasn't running into some rate limits on Twitter's API while I was testing it.
Trevor