Quick present, my code to post to Twitter without using their API

moomycow

New member
Jun 22, 2008
165
10
0
tweetingmachine.com
Hi all,

I've just quickly knocked up some code for updating a Twitter account's status without using Twitter's API. Instead it uses curl to log in and post via the Twitter front-end.

Tiny bit of scraping basically, and it means that any status updates appear as "via web" rather than "via API" or "via some random app."

Should be easy enough to grasp the general usage:

PHP:
include_once 'twit_parser.class.php';
include_once 'twit_crawler.class.php';
	
$tc = new Twit_Crawler('username', 'password');
$tc->update_status('hello lovely cows');

The code's pretty rough around the edges, didn't want to spend long on this as it's more for a personal project, but if you want something properly robust it shouldn't take long to put in some decent error handling etc.

Code should be attached, have fun!
 

Attachments

  • twitfun.zip
    1.8 KB · Views: 14


Well done!

It made sense for me to modify the one line to the cookie path to use DIRECTORY_SEPARATOR

Code:
$this->cookie_file_path = dirname(__FILE__). DIRECTORY_SEPARATOR . "eBay_cookies_".time().".txt";


edit: rep+
 
You're going to run into a problem at the end of this month. Twitter's turning off basic authentication for web services.

Countdown:
@twitterapi's countdown to Basic Auth removal

I used this guy's class:
How to quickly integrate with Twitter’s OAuth API using PHP :: Jaisen Mathai

Basically set up an app, had my bots visit it, kept their token/secret in a database table, use those to do the oauth call. My bots are *probably* less complex than yours, I use them for linkspam and to DM me messages.
 
You're going to run into a problem at the end of this month. Twitter's turning off basic authentication for web services.

Countdown:
@twitterapi's countdown to Basic Auth removal

I used this guy's class:
How to quickly integrate with Twitter’s OAuth API using PHP :: Jaisen Mathai

Basically set up an app, had my bots visit it, kept their token/secret in a database table, use those to do the oauth call. My bots are *probably* less complex than yours, I use them for linkspam and to DM me messages.

This code doesn't use Basic Auth. It also doesn't use OAuth. That's why I said it doesn't use Twitter's API. So, this won't be a problem :)
 
Well done!

It made sense for me to modify the one line to the cookie path to use DIRECTORY_SEPARATOR

Code:
$this->cookie_file_path = dirname(__FILE__). DIRECTORY_SEPARATOR . "eBay_cookies_".time().".txt";


edit: rep+

Thanks, and good catch! Saw that I'd left this in a couple of hours after posting it, can you guess what I'd previously been working on? ;)
 
  • Like
Reactions: mattseh