Lonnie Knows Everything

Programming

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, "

VN:F [1.9.3_1094]
Rating: +1 (from 1 vote)

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
Leave a Comment :, , , more...

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

VN:F [1.9.3_1094]
Rating: 0 (from 2 votes)

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
2 Comments more...

Advantages of PHP

by Lonnie on Aug.16, 2010, under Programming

PHP Hypertext Processor is a server-side internet computer computer programming language that may be embedded into hypertext markup language. PHP usages are widespread, and may include any kind of server functionality that accepts user’s input and shows or alters the input. PHP may execute on both UNIX operating system and Windows servers, which makes it handier than Windows (ASP). This scripting language is maturing daily. PHP5 is a fully object oriented programming language and its platform independence and speed on UNIX server helps to build big and complex World Wide Web applications.

(continue reading…)

VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

Incoming search terms:

  • open source music servers linux
Leave a Comment more...

Mass Content into Joomla’s K2 Component!

by Lonnie on Jul.27, 2010, under Joomla, Programming, Uncategorized

The Joomla Mass Content component is something I’ve used for a long time to help make the creation of sections, categories and articles much easier because it enables the developer to create all of these items on a single screen without having to jump back and forth in the control panel. This handy tool can eliminate hours of unnecessary development time by consolidating several screens into one.

In a previous blog entry (please refer to Joomla and K2, a True Romance Story), I mentioned some of the advantages of the Joomla K2 component. The obvious question is how can the K2 component and the Mass Content component work together when the Mass Content component creates standard Joomla content and the K2 component creates content that is managed outside of core system?

Fortunately, there is a solution that allows you to incorporate both components and reap the benefits of each. The K2 component has a very nifty feature that lets you import content. So, when developing a new website, as long as you follow these steps in the proper sequence, you should be fine.

1. Install the Mass Content component
2. Create your sections, categories and content items within the Mass Content component
3. When everything is set up as you like it, run the K2 article import

With step #3, the K2 system will turn Joomla sections into top level K2 categories and the standard Joomla categories into K2 sub-categories. In my experience with this, everything has gone without a hitch.

You can now start building your navigational structure in the K2 system and delete all of the items, categories and sections from within the core Joomla content system. With this approach, I hope you will find as I did, that despite using two additional components – K2 and Mass Content – you will save quite a bit of development time.

Related Links:
Mass Content Component – Download Link
K2 for Joomla – Download Link

VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

Incoming search terms:

  • k2 import joomla content
  • k2 bulk categories
  • joomla masscontent k2
  • k2 mass content
  • joomla k2 bulk
  • Mass Content Component
  • mass content k2
  • mass add category k2 joomla
  • mass category creation k2
  • k2 mass category creation
2 Comments more...

Joomla and K2, a True Romance Story

by Lonnie on Jul.27, 2010, under Joomla, Programming

As a professional developer, I’ve had quite a bit of experience working with the Joomla content management system and I can honestly say I’m very pleased with how versatile it can be in developing a broad range of website solutions. Where Joomla really shines is in its ability to be extended by way of modules, components and plugins that provide useful features that the core system doesn’t include.

Meet K2

The component “K2″ is an alternate content system for Joomla that provides many additional features, the most notable features that have proven to be invaluable are:

  1. Nested categories
  2. The capability to assign templates to categories
  3. Improved Access Control List (ACL)
  4. Article comments

There is far more to K2 than the features listed above, but these features have made an already powerful content management solution a much more robust package to say the least.

Utilizing nested categories and custom templates, TDH developers have been able to create a feature-rich product catalog, for example. The possibilities are endless and I’m excited to see what other magic can be conjured up with this powerful tool set.

Joomla can be found at http://www.joomla.org, and you can check out the free K2 component at http://getk2.org.

VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

Incoming search terms:

  • joomla k2 trackback
  • advantages features K2 joomla
  • joomla k2 component book
  • joomla k2 pingback
  • k2 trackback joomla
  • k2 true stories
  • movie k2 true story
  • trackbacks k2 joomla
1 Comment more...



Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...