POSTing to Twitter via php

r3dn4x

Newbie
Joined
Jul 7, 2008
Messages
30
Reaction score
7
I'm trying to POST a status update to twitter via curl, but I'm getting authentication errors. Is anyone doing this successfully? I don't want to use the API, just curl. I'm currently extracting the authenticity_token, but I'm still getting "could not authenticate". I'm posting to:

http://api.twitter.com/1/statuses/update.json

with form data:

PHP:
	$postData = Array(
	'include_entities' => 'true',
	'status' => 'ohmyhagosh',
	'post_authenticity_token' => $token
	);

This is still getting me authentication errors... anyone? Thanks
 
While waiting for a response from here you should try to post in phphelpforum too. those guys are realy good with coding.
 
I used to use a php class I found on google. But it stopped working some time ago. I think the only way now is to use the new api.

On August 16, 2010 the twitterapi team will be shutting off basic authentication on the Twitter API. All applications, by this date, need to switch to using OAuth. Read more

I wrote a new (wrapper)class that uses OAuth for authentication, so grab your copy.
 
Yeah, I figure there has to be some workaround for grabbing tokens? I see apps like TweetAttacks claiming they are POSTing via web and not API... gotta be some way?
 
Gotta start here for OAuth brother:

Code:
https://dev.twitter.com/apps/new

and probably reading this will be beneficial:

Code:
http://teeky.org/web-development/writing-php-application-using-oauth-twitter-api/

The best way to reuse code IMO is to borrow the php from a wp plugin called: "WP to Twitter" it'll get you accustomed to a lot of the hoops you have to jump thru. HTH.
 
If you choose to go through the regular web interface, then you have to send the right session cookies. Look at the cookies sent with Live HTTP Headers or Firebug. The authenticity_token isn't all you need.

API sucks, both because you have to sign up for API accounts and because it is extremely easy for them to track you. API accounts get banned faster than non API accounts in my experience.

I believe TweetAttacks makes it easy for themselves by implementing a Windows-esque full browser that executes javascript, but I haven't used the program so I could be wrong.
 
I was considering using PHP to send twitter auto-updates from a site but I think at this point I may opt for just outputting an RSS feed for what I want to send and have tweet adder blast that out.

I am sure I could get PHP->twitter to work, but for how long with their constant changes and also tweet adder solves the proxy/tracking issue.
 
Back
Top