Nerd Stuff
Post to twitter using PHP without using oauth or the API
by Lonnie on Mar.15, 2011, under Geek Stuff, Nerd Stuff, Programming
So you want to post twitter updates and perhaps follow people using PHP but you’re annoyed with that oauth implementation because it makes life difficult? no problem
I’ve constructed a class that implements two functions, posting a status update and following an author .. This is purely for educational purposes and is intended to demonstrate the art of page scraping as well as the use of CURL for posting and retrieving data, I would of course never personally recommend using the code because I’m sure it’s some sort of violation of their TOS ;) so yeah.. don’t do it! ;) ;)
Some important things to note:
1. This will break if twitter changes their html up too much
2. This is probably a violation, so if you do use it, use it reasonably .. don’t submit a million requests per second, throttle it down =)
3. You’re using it at your own risk
4. It will post status updates as if you posted from a mobile device ( Ie. Mobile Web )
DOWNLOAD: Click to download example and class file
USAGE:
include(“tweeter.php”);
$tweeter = new tweeter();
$tweeter->login($username,$password);
$tweeter->post_tweet(“Hey, this is cool!”);
$tweeter->folllow(“oneduality”);
Contents of tweeter.php:
class tweet {
var $user;
var $token='';
var $ch='';
var $action='';
// Logs in to twitter
function login($user,$pass) {
$this->user = $user;
// Initialize CH
if (!function_exists("curl_init")) die("This requires the CURL module, please install CURL for php.");
$this->ch = curl_init();
// Parse the login form
curl_setopt($this->ch, CURLOPT_URL, "https://mobile.twitter.com/session/new");
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($this->ch, CURLOPT_FAILONERROR, 1);
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($this->ch, CURLOPT_TIMEOUT, 5);
curl_setopt($this->ch, CURLOPT_COOKIEJAR, $this->user . ".txt");
curl_setopt($this->ch, CURLOPT_COOKIEFILE, $this->user . ".txt");
curl_setopt($this->ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3 ");
$page = curl_exec($this->ch);
$page = stristr($page, "
");
preg_match("/form action=\"(.*?)\"/", $page, $this->action);
preg_match("/input name=\"authenticity_token\" type=\"hidden\" value=\"(.*?)\"/", $page, $this->token);
// Login and get your home page
$strpost = "authenticity_token=".urlencode($this->token[1])."&username=".urlencode($user)."&password=".urlencode($pass);
curl_setopt($this->ch, CURLOPT_URL, $this->action[1]);
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $strpost);
$page = curl_exec($this->ch);
// Verify that we logged in ok
preg_match("/\
(.*?)\<\/div\>/", $page, $warning);
if (isset($warning[1])) return $warning[1];
$page = stristr($page,"
");
preg_match("/form action=\"(.*?)\"/", $page, $this->action);
preg_match("/input name=\"authenticity_token\" type=\"hidden\" value=\"(.*?)\"/", $page, $this->authenticity_token);
}
function post_tweet($status) {
// Set status
$tweet['display_coordinates']='';
$tweet['in_reply_to_status_id']='';
$tweet['lat']='';
$tweet['long']='';
$tweet['place_id']='';
$tweet['text']=$status;
$ar = array("authenticity_token" => $this->token[1], "tweet"=>$tweet);
$data = http_build_query($ar);
curl_setopt($this->ch, CURLOPT_URL, $this->action[1]);
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $data);
$page = curl_exec($this->ch);
return true;
}
function follow($author_name) {
$action = "http://mobile.twitter.com/$author_name/follow";
$ar = array("authenticity_token" => $this->token[1], "tweet"=>$tweet, 'last_url'=>'/$author_name', );
$data = http_build_query($ar);
curl_setopt($this->ch, CURLOPT_URL, $action);
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $data);
$page = curl_exec($this->ch);
return true;
}
}
Incoming search terms:
- curl login to twitter without Oauth
- php post to twitter 2011
- tweeter api php oauth
- post to twitter without oauth
- twitter php api
- Posting to Twitter using PHP
- post to twitter php 2011
- php post twitter without api
- How to post to twitter with php and Curl without oAuth
- post twitter via php 2011
Clear your facebook wall entirely with Greasemonkey and Firefox
by Lonnie on Dec.13, 2010, under Programming
Previously I posted a perl script who’s job was to clear out your wall posts, it worked but was slow and with the recent facebook updates.. it may no longer function.
I was browsing for an alternative that was simple and stumbled on a greasemonkey script to clear recent activity, adapted that code to suit my needs and the result is my greasemonkey wall cleaner.
http://userscripts.org/scripts/show/92664
Incoming search terms:
- facebook wall cleaner
- clean facebook wall
- CLEAR FACEBOOK WALL
- facebook clear wall
- greasemonkey facebook wall
- greasemonkey delete facebook wall
- greasemonkey facebook wall cleaner
- greasemonkey clear facebook wall
- clear facebook wall greasemonkey
- wall cleaner facebook
Credit Karma – My Review
by Lonnie on Nov.03, 2010, under Commentary, Reviews
Let me start by stating for the record that I have no affiliation with Credit Karma ( www.creditkarma.com ) at all .. I found them using a google search while looking for an alternative to freecreditreport.com since I got stuck with them before and had a hard time cancelling. I was looking for something that was TRULY free..
I found Credit Karma when someone suggested it as an alternative via a yahoo question someone asked, so I decided to do my own research and read a few positive reviews before deciding to try it out for myself.. so without further delay..
Truly Free
During the signup process they don’t ask for any banking information or for a credit card, they do require you to give over your social security number, which is expected since that information is required in order to do a credit inquiry. They also asked a couple of questions to verify that I am who I claimed I was, some multiple choice questions based on information the gleaned from my credit history.
Intuitive Interface
It’s very simple to navigate the site, everything is pretty well self explanatory and the information is easy to find! While the site is indeed ad supported, the ads are not intrusive and there are no popups.
Useful Tools
The site provides a few useful tools such as the ability to compare credit cards, Auto Insurance, Banks.. etc .. But one of the most useful tools I found was the Credit Simulator that lets you see the results of certain actions on your credit score. I was able to see for example, what adding a new credit card would do to my credit … This was very useful to me in deciding what actions I would take to improve my score.
Unlimited Credit Queries
That’s right, you can go back every day and check your credit score if you like and it won’t hurt you because they are doing a soft check as opposed to a hard check. Basically they are just getting the basic information which is free. When you go in for a loan or apply for a new credit card, the issuer will typically do a hard check and too many of those will damage your credit score. Worth mentioning here is that one of the bits of information that Credit Karma provides, is the ability to show you how many hard checks have been made against you.
The Bad
There’s not much negative I can say about Credit Karma except that you don’t get specifics about what is knocking your score down, it showed that I have an auto loan but it doesn’t tell you who the loan is with.. so if there were some bad stuff on there I wouldn’t know where to go to correct it. With that said, Credit Karma is still immensely useful as an indicator that something is wrong.. When you sign up, you have the option to have a monthly e-mail go to you that will tell you your score.. If you notice a signifigant drop, you can take further action by going to www.myfico.com directly and pulling your credit information up for a fee. www.myfico.com is as good as it gets for getting your credit score in detail because these are the people who created the algorythm that your score is based on.
Con or not?
I can’t say for sure, I can only say that nothing has happened to me.. they don’t ask for payment and I’ve not receieved any junk mail! the community seems helpful and the information / tools are useful .. I would recommend it to any of my friends!
Bottom Line: I strongly recommend Credit Karma ( www.creditkarma.com ) .. as with anything like this, always do your own research before handing over your personal information. I’m not responsible for you, only you are =)
Incoming search terms:
- credit karma scam
- creditkarma com review
- credit karma reviews 2010
- creditkarma com scam
- CreditKarma com reviews
- credit karma alternative
- credit karma review 2010
- is credit karma safe
- Search creditkarma
- credit score what if simulator
i675 Crash Update – Brennan Eden Out of ICU, Doesn’t Remember Accident.
by Lonnie on Sep.01, 2010, under Commentary, News and Events
Update: Police found no evidence of drugs or alcohol in Brennan’s Body ( blood results from the morning he was taken to the ICU )
Update: Brennan commented ( see below ) and the post has been updated to it’s final state.
Sunday night I was informed by someone who’s a friend of the Eden family that Brennan was released from the intensive care unit at Miami Valley Hospital. This doesn’t mean that he will be released from care any time soon as I imagine his injuries are significant. What I do know at this point is that he has no brain damage which is a very excellent sign despite the fact that he doesn’t remember anything about the accident at this time.
Memory loss after such an extreme accident isn’t uncommon, Brennan may recover some memory from the accident, but the chances of him actually remembering enough detail to shed light on what happened seconds before going off the road are slim to none in my honest opinion.
There have been numerous theories thrown around about the cause of this near tragedy, such as:
- Brennan was attempting to commit suicide – False
- Brennan’s accelerator was stuck – False
- Brennan fell asleep - I accept this as what happened
- Brennan was drunk, high or both – Officially disproven ( see update above )
- Brennan thought he could out run the police – False
- Brennan was being chased by police – Officially disproven ( I was there )
At the end of the day, none of this can be proven as true without getting into Brennan’s head and without his memory of the events, I don’t think any of these theories will be proven or dis-proven any time soon.
So what do we know? all we know are the facts and the facts don’t really support a lot of the theories that have been tossed around..
Am I angry with Brennan? not at all .. not in the very least. I wish him a quick recovery, I wish the best for his friends and Family .. and I hope that one day we can all truly understand what happened.. but most importantly, I hope Brennan realizes just how lucky he really is.. he not only survived the horrific crash, he survived being ejected hundreds of feet.. AND .. came within 10 feet from me running him over.. so he should also thank the manufacturer of my breaking system :)
Incoming search terms:
- brennan eden
- brennan eden update
- brennan eden crash
- Brennan Eden INJURIES
- Brennan S Eden
- brennen eden
- brennan edan
- brennan s Eden update
- i675 crash
- brennan s eden dies
Software Review: Tweak Me! Portable tweaks for all modern versions of Windows
by Lonnie on Aug.19, 2010, under Reviews
My computer at work is in need of a memory upgrade and there’s just some general sluggishness going on, so when I was browsing lifehacker.com I came across a useful piece of software called Tweak Me! This software is similar to many other windows tweaking tools out there except that it’s portable and can be carried around on your flash drive.
If you have a windows based machine and you’re looking for a small, clean, portable tweaking tool then this is your lucky day :) here is some additional information from the author’s web site.
Key Features:
- Supports Windows XP, Windows Vista and Windows 7
- Creates System Restore Points for maximum security
- 172 tweaks which greatly improve your system’s performance and stability
- Easy to use, different colors show the tweaks’ recommendations
- Cleaner module which helps you to keep your system clean
- Portable, clean application! (for more information see requirements)
Example Tweaks:
- Disable User Account Control (UAC)
- Disable Windows Defender
- Disable Error Reporting
- Disable Search Indexing
- Tweak Internet Explorer, Windows Media Player, Windows Update, Security Center
- Enable Aero (also on Home Basic Editions but without transparency)
Overall I’d say on a scale of 1-10 this gets a 9 for me! Way to go guys
* Supports Windows XP, Windows Vista and Windows 7
* Creates System Restore Points for maximum security
* 172 tweaks which greatly improve your system’s performance and stability
* Easy to use, different colors show the tweaks’ recommendations
* Cleaner module which helps you to keep your system clean
* Portable, clean application! (for more information see requirements)
Examples of Tweaks:
* Disable User Account Control (UAC)
* Disable Windows Defender
* Disable Error Reporting
* Disable Search Indexing
* Tweak Internet Explorer, Windows Media Player, Windows Update, Security Center
* Enable Aero (also on Home Basic Editions but without transparency):
Incoming search terms:
- tweak me review
- tweak me! review
- tweak me portable
- tweakme portable
- tweakme review
- portable tweak
- tweekuii portable
- what is Enable Aero in Home Basic Editions but without transparency
- windows 7 tweak me portable
- portable tweaking