tweeting pipes

…but serious, channels on Twitter are a hot item.

Twitter seem to want branded channels for commerce by using verified accounts to prevent spoofing celebrities, and the same goes for brandnames. There is already a growing trade in twitter accounts like @nike-shoes, @skyeurope.

To build an attractive channel I need credibility, provide regular good quality fresh content, so where do I get that :

Yahoo pipes

I am very lazy and Yahoo have a nice example online, the news aggregator with 14 sources like blogsearch, icerocket, technorati, that you can clone and use out of the box. So I cloned it, replaced the technorati api key and run the pipe with ‘banking’ as keyword. I grab the rss feed url and read that with simplexml (you can use that pipe with any keyword).

Then I take a twitter php api class from sourceforge (it only reads the account, it doesnt have the post-routines), by simon wippich, wire in the rss-feed and start posting content.

  1. require_once('twitter.class.php');
  2. $Twitter = Twitter::getInstance();
  3. $Twitter->setUser('Account','SomePassword');
  4.  
  5. $rss= simplexml_load_file("http://pipes.yahoo.com/pipes/pipe.run?_id=1234567890&_render=rss&textinput1=banking");
  6.  
  7. if($rss)
  8. {
  9.     foreach($rss->channel->item as $e)
  10.     {
  11.         $shrunk = file_get_contents('http://bit.ly/api?url='.$e->link);
  12.         $msg = trim(substr($e->title, 0, (137strlen($shrunk)))).' '.$shrunk;
  13.         $output = $Twitter->post($msg);
  14.     }
  15. }

neofinance

Now I can post proper stuff.

The second part of a channel is the audience.

Where to get my audience ?

Google Search

Google serp scrapers are always good for 1000 targetted results on any keyword : i use
allinanchor:twitter.com/ site:twitter.com banking
as search phrase, that gets me 95% valid accounts with my keyword banking in the description

  1. $key = 'banking';
  2. //scrape urls
  3. $urls = twt_Google('allinanchor:twitter.com/ site:twitter.com '.$key);
  4. //get the account names
  5. $accounts = twt_Google_getaccounts($urls);
  6.  
  7. function twt_Google($keywords, $pages=1) {
  8. //scrape results off of google serp    
  9.     $lang='en';
  10.     $results=100;
  11.     for($i=0;$i< $pages;$i++){
  12.         $start = $i*100+1;
  13.         $vargoogleresultpage = "http://www.google.com/search?as_q=".urlencode(trim($keywords))."&num=".$results."&start=".$start."&hl=en&lr=lang_en";
  14.         $googleresponse = join("",file($vargoogleresultpage));
  15.         $googlehits = preg_split('/class=r><a /', $googleresponse, -1, PREG_SPLIT_OFFSET_CAPTURE);
  16.         $i=0;
  17.         foreach($googlehits as $googlehit){
  18.                 $i++;
  19.                 preg_match("/href=\"(.*?)\"/", $googlehit[0], $t, PREG_OFFSET_CAPTURE);
  20.                 $the_urls[] = $t[1][0];
  21.         }        
  22.     }
  23.  
  24.     //return a set with twitter urls http://www.twitter.com/account
  25.     return $the_urls;
  26. }
  27.  
  28. function twt_Google_getaccounts($arr) {
  29. //get the account name from the twitter-url
  30.     for($i=0;$i<count($arr);$i++){
  31.         $parts = explode('/', $arr[$i]);
  32.         //account is 3 : http: // … / account
  33.         $myaccounts[] = $parts[3];
  34.     }
  35.     return $myaccounts;
  36. }

There is my audience, lets make some friends :

  1.  
  2. for($i=0;$i<count ($accounts);$i++){
  3.      followthisone($accounts[$i], 'Account','SomePassword');
  4. }
  5.  
  6. function followthisone($accountname, $name, $pass) {
  7.     $url = "http://twitter.com/friendships/create/".$accountname.".xml";
  8.     $ch = curl_init();
  9.     curl_setopt($ch, CURLOPT_URL,$url);
  10.     curl_setopt($ch, CURLOPT_POST, 1);
  11.     curl_setopt($ch, CURLOPT_USERPWD, $name.":".$pass);
  12.     $result= curl_exec ($ch);
  13.     curl_close ($ch);
  14. }

hello friends!

Anyways, that’s the basic ingredients of a marketing channel, proper content and an audience.