Stammy Script: RSS to Twitter using PHP

January 26, 2007 · 166 comments

I’ve been a Twitter user for a few weeks now and have come across many tools to help with Twitter posting and integration. I have also seen several Twitter mashups that essentially do RSS to Twitter and have become rather popular. At first it might sound stupid to use Twitter for syndication instead of tried and true RSS, but simply put, Twitter users are always aware of Twitter happenings, creating a more effective syndication experience. I like to call it micro-syndication as you only have 144 characters to get your point across.

After a bit of research the best way I could find to carry out RSS to Twitter involved a Jabber bot package for Ruby. Not too many people have access to a Ruby-enabled server so I decided to make a simple PHP script to get the job done. My code might not be the most efficient way of doing this, but here’s how it works:

  1. A cron job accesses the PHP script as often as you like.
  2. Utilizing lastRSS, the script grabs the latest post from the RSS feed you specify within the file.
  3. The script grabs the link to the article and uses the TinyURL API to create a shortened URL.
  4. PHP concatenates article title and tiny url to form a Twitter status message.
  5. Using the login and password you provided in the file, the script uses CURL to tap into the Twitter API and update the status message.
  6. The script doesn’t utilize RSS caching or any logic (which would have been nice) to determine whether the post is the same as the one currently on Twitter – but thankfully Twitter is smart enough to avoid posting duplicate status messages. That way, if your cron job calls the PHP script every 15 minutes and the feed hasn’t been updated in the last day, you won’t have a Twitter account full of the same status messages.

If you don’t know how to use or setup a cron job to execute the script, you can just run the script manually whenever your feed gets updated. For example, if you have a Twitter account just for your blog notifications, just hit up the script whenever you post a new article. However, if you want to make a standalone RSS to Twitter setup, you can try to grok this article on working with cron jobs.

Download RSS to Twitter v0.1 (4 kB)

RSS to Twitter Source Code
The main source code for RSS to Twitter v0.1, based on this code.

Installation

  1. Download, unpack and upload to a public directory on your server. Ensure the files are at a CHMOD so that your Twitter login info is safe. CHMOD 644 should be fine.
  2. Open tw.php and edit $uname, $pwd, $feed with your Twitter login, password and the RSS feed you want the script to access, respectively.
  3. Save and test it out.

Comments

RSS to Twitter, as I’m calling it, is very basic and was the result of a spur of the moment coding session. LastRSS supports feed caching so in the future it’s very possible that I could develop a version smart enough to not attempt double posting, thus saving bandwidth (although it’s rather negligible). If you have any suggestions or code you’d like to see in this, please feel free to contact me and I’ll merge it in – consider it open source.

Download RSS to Twitter v0.1 (4 kB)

{ 92 trackbacks }

mcdave.net » links for 2007-01-27
January 27, 2007 at 1:28 am
Henry’s blog » Twitter
January 28, 2007 at 1:41 am
Twitter For Marketeers By PStam | Am I Famous Now…
January 28, 2007 at 2:22 pm
Library clips :: Twitter : what are the possibilities. :: March :: 2007
March 13, 2007 at 9:39 pm
nonsmokingarea.com » Blog Archive » RSS to Twitter / PLAY.FM
March 18, 2007 at 1:57 pm
Twitter: recursos para una idea simple y feliz | 5líneas.com | Internet, desarrollo web, tecnología y otras cosas por descubrir
March 19, 2007 at 4:57 am
Twitter Tools Collection » Freakitude
March 21, 2007 at 2:33 am
#!/usr/bin/geek
March 21, 2007 at 3:00 pm
Tech, Life and Jayson! » Blog Archive » Twitter tricks, tips and tools
March 23, 2007 at 12:46 am
Put Your Site’s Feed In Twitter
March 23, 2007 at 1:39 am
My Stuff :: Site RSS to Twitter
March 23, 2007 at 7:35 am
YouMix
March 26, 2007 at 4:44 am
RSS to Twitter Enables Lifestream Broadcasting : erinpettigrew.com
March 27, 2007 at 3:04 am
The sky of Daemon! » links for 2007-03-23
March 30, 2007 at 2:44 am
10 Best Twitter Tools for Wordpress Blogs
April 11, 2007 at 10:19 am
Miguel Pena Roma - Miguel Pena Roma » Las mejores 10 herramientas de Twitter »
April 13, 2007 at 7:23 am
Las 10 mejores utilidades de Twitter para Wordpress » BlogMundi
April 14, 2007 at 9:33 pm
Las 10 mejores utilidades de Twitter para Wordpress « Cosas sencillas
April 16, 2007 at 4:58 am
笨笨包的天空 » 在WordPress中10種最佳的Twitter工具
April 24, 2007 at 4:46 pm
Twitter Tools | One Tip A Day
May 2, 2007 at 5:14 pm
Twitter for Your Wordpress Installation | All Things Twittered
May 3, 2007 at 6:29 am
Plod
May 5, 2007 at 12:49 am
TipMonkies » Blog Archive » 10 great tools to help you Twitter better
May 7, 2007 at 10:34 pm
  Make Yourself Found! (Or, Promote Your Site Web 2.0-Style) by Blog Tutorials
May 13, 2007 at 4:02 pm
Plugins.Net.Ru
May 30, 2007 at 2:30 am
links for 2007-06-10 « Attractive Verdana
June 10, 2007 at 11:28 am
» Twitter para Wordpress Ganha dinheiro online com MUIOMUIO.NET: Internet, Tecnologia e dicas sobre Blogging por Mario Andrade
June 14, 2007 at 12:18 pm
GRATIS EN INTERNET » Twitter: recursos para una idea simple y feliz
August 24, 2007 at 3:52 am
The 10 Best Twitter Tools for Wordpress Users | dailyApps
September 4, 2007 at 11:04 am
tips and tricks - Page 4 - Google Community
September 17, 2007 at 12:06 pm
Rojoro & Ray----two become one » twitter工具收集
October 1, 2007 at 12:42 am
Microblogging With urlTea - My Twitter Bookmarklet at myopiclunacy.com
November 14, 2007 at 3:30 pm
TermiT’s Blog » Blog Archive » Десять плагинов интеграцÐ
November 19, 2007 at 6:11 am
Twitter en blogs Wordpress - Incubaweb 2.0 Bitácora del Software, Web 2.0, Beta, Windows, Linux, Mac OS X, Open Source, ....
November 27, 2007 at 5:13 am
Speakorama! Cultura+Viral+Música+Cinema+Game » Blog Archive » 10 Dicas para Melhorar o Twitter
November 27, 2007 at 11:37 am
links for 2007-12-05 | a minor technicality
December 5, 2007 at 3:24 am
Ferramentas úteis para o Twitter
December 26, 2007 at 9:59 am
Integrar Twitter en Blog Wordpress | CiberPrensa
January 3, 2008 at 3:01 am
Integrar Twitter en Blog Wordpress | CiberPrensa
January 3, 2008 at 3:01 am
10 utilidades de Twitter para Wordpress
January 3, 2008 at 5:25 am
Twitter en tu Blog | Ayuda Wordpress
January 19, 2008 at 9:26 pm
PerformSec Blog » Blog Archivo » Las 10 mejores utilidades de Twitter para Wordpress
March 25, 2008 at 11:35 am
A Guide To Twitter: What It Is, How To Use It And Twitter Tools | Lost Art Of Blogging
April 7, 2008 at 3:03 pm
JOBMATCHBOX » Blog Archive » Twitter Tools
April 17, 2008 at 11:29 am
[arte e vício] » arquivo » 10 ferramentas para integrar o twitter ao seu blog wordpress
April 19, 2008 at 3:46 pm
Tough Monkey » Blog Archive » 47 Twitter Tools
May 9, 2008 at 1:18 pm
Top 10 Most useful Twitter Tools list for PC, mobiles and blogs | Web 3
May 10, 2008 at 10:10 am
10 ابزار مفید تویتر برای وردپرس « تک نویس
May 15, 2008 at 8:03 am
» 1000 ressources pour le développement web et WordPress : la grosse grosse liste « css4design : des css pour votre design html
May 16, 2008 at 7:44 am
» 1000 ressources pour le développement web et WordPress : la grosse grosse liste « css4design : des css pour votre design html
May 16, 2008 at 7:44 am
Leverage The Secret
July 19, 2008 at 4:22 pm
Ganar mas visitas con Twitter, los mejores plugings | Dinerofair
July 24, 2008 at 9:17 am
Twitter Tools must have for Wordpress Blogs | Mr Fighter Make Money Online - Affiliate Marketing
July 25, 2008 at 1:57 am
Twitter Wordpress Plugins : Wordpress Plugins
August 4, 2008 at 9:46 am
WordPress中的10佳Twitter工具 | WFan's Blog
September 4, 2008 at 1:21 pm
Ferramentas úteis para o Twitter | Mateus Souza - Revolucionando a Web
September 4, 2008 at 6:48 pm
Smashing Collections » Blog Archive » Twitter
September 20, 2008 at 1:56 pm
Some Of The Best TWITTER Tools On Net | DCL-Network.Com
October 7, 2008 at 4:50 am
12 meilleurs outils Twitter pour blogs WordPress | Ya-graphic Design
November 2, 2008 at 3:29 pm
一些关于Twitter有用的工具 | 软件集散地
November 14, 2008 at 2:50 am
Top 25 twitter tools for Wordpress | honeytech
November 18, 2008 at 7:46 am
20 Twitter Status Design Tutorials, Icons & WP Plugins | Noupe
November 19, 2008 at 5:55 am
20 Twitter Status Design Tutorials, Icons & WP Plugins | virology.tv
November 20, 2008 at 12:02 am
20 Twitter Status Design Tutorials, Icons & WP Plugins | SulVision
November 27, 2008 at 4:40 pm
12 Tools To Synchronize Wordpress And Twitter | Smart Advi$e.info
November 30, 2008 at 5:53 am
20 Twitter Status Design Tutorials, Icons & WP Plugins | Link Archive
December 6, 2008 at 5:30 pm
20 Twitter Status Design Tutorials, Icons & WP Plugins | Link Archive
December 6, 2008 at 5:30 pm
Leonardo Teleanu » Cele mai bune 10 Twitter tool-uri pentru Wordpress
December 16, 2008 at 9:58 am
Herramientas Twitter para tu blog | Codigo Geek
December 22, 2008 at 12:13 pm
Twitter: Coolest network on the internet « Ovylord’s Blog
January 2, 2009 at 7:10 am
Wordpress till Twitter | Andreas Karman
January 10, 2009 at 5:00 pm
twitter aps | Nickita's Blog
January 14, 2009 at 8:05 pm
Twitter第三方应用汇总 | 天涯海阁 | Web2.0Share
February 7, 2009 at 12:55 am
Twitter第三方应用汇总 | 软件集散地
February 7, 2009 at 10:00 pm
twitter插件大全 | 哲学笔记
February 17, 2009 at 12:13 pm
WordPress中的10佳Twitter工具 | 独立博客空间站
February 18, 2009 at 6:12 am
twitter插件大全 « 过把瘾就死
February 18, 2009 at 4:13 pm
Dreamfeel - Joao Ledo Fonseca
February 25, 2009 at 10:49 pm
Birdsall’s Massive Twitter Sites & Tools Directory - Birdsall Social Media
April 4, 2009 at 2:39 am
Twittermania
April 11, 2009 at 6:06 pm
La utilidad de Twitter para una comunidad universitaria
April 14, 2009 at 12:29 am
Using Twitter Effectively | Twittazon
April 18, 2009 at 5:50 am
Twister | Acho Aki
April 22, 2009 at 8:37 pm
PT Ubuntu Blog » Blog Archive » 无数个WordPress Twitter 插件
April 24, 2009 at 2:08 am
Stammy Script: RSS to Twitter using PHP
April 27, 2009 at 2:28 am
Twitter: Why It’s So Great And How To Effectively Use It | Twitter Bootcamp
May 2, 2009 at 10:07 pm
Ferramentas para Twitter | #twitterBH
May 8, 2009 at 10:17 am
Twitter Apps | TwitterMuscle.com
May 11, 2009 at 9:53 pm
Top 22 Twitter Tools For Wordpress Blogs | SEO Services
May 21, 2009 at 10:19 pm
Twitter Tools - My List - Digital Capital Strategies
May 26, 2009 at 12:42 pm
Chris Fernando Dot Net » Blog Archive » Best Twitter Tools for Wordpress Blogs
June 11, 2009 at 7:06 am
Twitter Links :: Twittermania
June 11, 2009 at 11:41 pm

{ 74 comments… read them below or add one }

1 titanium_geek January 26, 2007 at 2:50 am

nice. I just had to comment on your use of “dude” in the error messages. :D

Reply   More from author

2 conedude13 March 20, 2007 at 6:26 pm

I’m testing this out right now and i get the following error when navigating to the tw.php file:

Fatal error: Call to undefined function: curl_init() in /home/www/filewarehouse.awardspace.com/twitter/tw.php on line 23

What version php did you get it to work for yourself? The host I am using has version 4.4.1.

Reply   More from author

3 Paul Stamatiou March 20, 2007 at 6:42 pm

@Ryan – you need to have PHP with CURL support. I believe I had the same version of PHP (4.4) you do. I’m looking into another way without CURL.

Reply   More from author

4 conedude13 March 20, 2007 at 6:49 pm

Just looked into curl support on the server I’m using and it says that it is enabled. It also give the following info on the curl support:

libcurl/7.13.2 OpenSSL/0.9.7e zlib/1.2.2 libidn/0.5.13

I’m using AwardSpace for the hosting needs.

Reply   More from author

5 Paul Stamatiou March 20, 2007 at 6:59 pm

Hrm, the error says it can’t find curl_init() which is part of any php greater than 4

http://us2.php.net/manual/en/function.curl-init.php

not sure what to say, but ill ask around.

Reply   More from author

6 conedude13 March 20, 2007 at 7:41 pm

I did a quick switch to another free host. I think the first one had disabled curl support, but never bothered to update their faq’s about it. Now i’m getting the following output from the tw.php file when browsing directly to it:

Error
success

Is that correct now?

Reply   More from author

7 Paul Stamatiou March 20, 2007 at 7:54 pm

I believe that error is coming from TinyURL – does the URL you are trying to use have a & in it? It currently chokes on that.

Reply   More from author

8 conedude13 March 20, 2007 at 8:18 pm

This is what I have:

$tiny_url = file_get_contents(”http://tinyurl.com/api-create.php?url=” . $url);
$status = $title . ” ” . $tiny_url;
echo $status; //just for status if you are directly viewing the script
$curl_handle = curl_init();

No “&” there. Any other thoughts?

Reply   More from author

9 conedude13 March 20, 2007 at 8:21 pm

There are no “&” in the entire file. I have the version that is available through the download link above. Any other possible thoughts? I’ll also test out another host.

Reply   More from author

10 Paul Stamatiou March 20, 2007 at 8:56 pm

Ryan – I meant if the URL you are trying to run through TinyURL has an & in it.

Reply   More from author

11 conedude13 March 21, 2007 at 8:33 pm

Thanks, Paul, for all your help. It turns out it was the site rss url that was the problem. It was all fixed up by “laundering” the rss feed through a yahoo pipe and using the pipe url in the tw.php file. It rocks!

Reply   More from author

12 george March 22, 2007 at 11:29 pm

Very cool! I DO seem to be getting some repeats, though… are you sure twitter protects against them?

http://twitter.com/dirtygreek

Reply   More from author

13 george March 23, 2007 at 9:24 am

I’ve made a change to the parse.php script to use lastRSS’s cache feature. It checks the current rss feed against its cache and only attempts to post to twitter if there is a change. I THINK it’s working correctly.

in the tw.php script, you need to add

$rss->cache_dir = ‘./rsscache’;
$rss->cache_time = 3600; // one hour

but be sure to set the cache_dir variable to your own cache directory, and chmod that directory so that it’s writable from the script. Info on this is available on the lastrss website.

In parse.php, I basically replaced

if ($timedif cache_time) {
// cached file is fresh enough, return cached array
$result = unserialize(join(”, file($cache_file)));
// set ‘cached’ to 1 only if cached file is correct
if ($result) $result['cached'] = 1;
}

with

if ($timedif cache_time) {
// cached file is fresh enough, return cached array
$result = unserialize(join(”, file($cache_file)));
$result2 = $this->Parse($rss_url);
if(count(array_diff($result,$result2))

Reply   More from author

14 george March 23, 2007 at 9:26 am

My comments apparently got cut off, so just email me if you are interested. george at dirtygreek dot org.

Reply   More from author

15 Chris Campbell March 23, 2007 at 11:35 pm

Hi, great work! I can’t get it to work though. I keep getting the RSS file not found message. I have tried different feeds and none seem to work. Ideas on what I am doing wrong?

Reply   More from author

16 george March 26, 2007 at 10:03 am

I’ve done some more fun stuff using (at least partially) Paul’s code and methods, but for some reason I had to use patRSS instead of lastRSS. Anyway,

http://www.dirtygreek.org/journal/journalId/2042

What this script does is read a Google Calendar feed and check each event’s time against the current time. If the event’s time falls within a given span around the current time (default is one hour), it will post the event’s details to Twitter. In other words, Google Calendar will tell Twitter what you’re doing at the current time.

Reply   More from author

17 Bgal April 1, 2007 at 9:15 pm

I keep getting the “Error: RSS file not found, dude.” error, even though the RSS file does exist – I’m linking directly to it, and have checked it by going directly to the rss file in a browser and getting the expected xml page. Any ideas why I’d be getting this error?

Thanks in advance for any help!

Reply

18 John Thompson April 17, 2007 at 1:01 pm

Cool script. One problem though – occasionally hiccups and sends the error message to Twitter, which is obviously not ideal. (ie [twittername]: Error)

Reply   More from author

19 David June 14, 2007 at 6:56 am

Nice script, thx a lot! It works just fine on my integration of Twitter and Plazes: http://dlinsin.blogspot.com/2007/06/twittering-with-plazes.html

Regards, David

Reply   More from author

20 Damon Kiesow June 16, 2007 at 11:24 am

Looks like something changed on Twitter. After 2 months – suddenly at midnight I have been getting duplicate posts of the latest status message every time the script runs. Any thoughts?

Reply   More from author

21 David June 17, 2007 at 6:02 am

Hey guys,

I implemented a simple check to prevent multiple updates, check it out if your are interested:

http://dlinsin.blogspot.com/2007/06/twittering-with-plazes-fix.html

Reply   More from author

22 Paul Stamatiou June 24, 2007 at 1:54 pm

@Damon, I’ll have to check that out. I haven’t messed with the script in quite a while due to other obligations.

Reply   More from author

23 Erik van Roekel July 27, 2007 at 3:04 am

It worked for a few days, but with nothing changes I only get ‘Disallowed Key characters’ as output. Can anyone give a hint what’s going wrong?

Reply   More from author

24 Davide Salerno September 1, 2007 at 4:30 am

The script seems to have some problems: it doesn’t cut the username at the beginnig of the message and it doesn’t update the twits regularly.

Have you got some ideas in particularly for the second problem?

Reply   More from author

25 Joel Ramos November 16, 2007 at 8:07 pm

I’ve tried this script and I’ve noticed that Twitter doesn’t check for duplicated posts like you have said.

Is it need to activate any option?

Reply   More from author

26 Robert November 18, 2007 at 5:51 pm

Thanks for the script. It worked like a charm for me @campascca

Appreciate you sharing this with all of us!

Reply   More from author

27 John Eckman January 3, 2008 at 3:51 pm

Dreamhost (and others) doesn’t allow @fopen with external urls – I’ve modified parse.php to use curl instead to get the rss file – email me if you’d like a copy.

(I will also let LastRS known and share the modifications back to them if they want them)

Reply   More from author

28 Woody January 16, 2008 at 7:30 pm

hello,

i tried this on my blog, but it wont send notification to twitter unless i go to http://www.myblog.com/tw.php then it tells me success and i receive the message.

this is the normal thing to do? or is there any problem?
thank you.

Reply   More from author

29 Robb May 6, 2008 at 1:52 pm

Is there another choice for CHMOD? My CronJob seems to want something that allows executable (ie, 775)

Reply

30 emlak May 19, 2008 at 6:30 pm

Nice script. I gonna use it on my blog to automaticcaly send new articles to twitter.

Reply   More from author

31 Jamie June 15, 2008 at 11:07 am

This is great – and perfect for the site I’m building. Thanks!

Reply   More from author

32 Jeff Coel July 3, 2008 at 7:23 pm

Hello Paul, there is a small and easy-to-use PHP library for sending messages to Twitter and receiving status updates – http://phpfashion.com/twitter-for-php

Reply

33 Paul Stamatiou July 4, 2008 at 1:52 pm

Thanks for the link Jeff – Unfortunately it relies upon php5/simplexml which not many people have on their servers. I love simplexml though, much easier to work with http://paulstamatiou.com/2007/04/17/how-to-parse-xml-with-php5

Reply   More from author

34 Bruce October 13, 2008 at 6:23 pm

How can I add a comment to the script the puts “Most Current Podcast” at the start of the twitter message.

Thanks for any help

Reply

35 Josh December 2, 2008 at 7:55 am

I was just wandering how to change the “from web” tag at the end of the twit
I would love it to say from MyWebsiteName.com
great for SEO

Reply

36 Jeromy December 11, 2008 at 7:37 pm

Great script! How do I get it to add more than one twit though? Is that all it adds the first time around or will it eventually add more?

Reply

37 Dale December 22, 2008 at 12:56 am

I heard that the guys who created jobfeedr.com are releasing their RSS to twitter technology for public release in the next few weeks, so I guess when that comes out you might be able to get muiltiple feeds into the one twitter account Jeromy.

Reply   More from author

38 Midas7g January 22, 2009 at 4:21 pm

Thanks for this script, Paul! I modified it to keep track of my World of Warcraft server status. https://twitter.com/ravenholdt

Reply

39 Jo February 2, 2009 at 2:48 pm

Thanks for the script, I have put my weather station onto Twitter! @budawx

Reply   More from author

40 mayooresan February 16, 2009 at 2:57 pm

There are 2 files found. Which file should be ran?
when I try those files, I got 404 error :(

Please help me

Reply   More from author

41 mayooresan February 16, 2009 at 3:06 pm

There waz small problem with chomod settings.. I got it correct thanks :D

Reply   More from author

42 mayooresan February 17, 2009 at 2:28 pm

when I run it manually it works fine.. but when I try to cron job it it makes duplicate posts in twitter :(

Reply   More from author

43 Emma February 23, 2009 at 10:09 am

I found your script which is great, however despite apostrophes showing correctly in the feed, they’re showing as \’ on Twitter. I think this is an escape character issue, but wouldn’t know where to start to correct it. Any clues?
Thanks,
Emma

Reply

44 Paul Pullen March 4, 2009 at 2:52 am

Having problems with Twitterfeed…but this script worked like a charm. Now I’m in control of how often my site’s RSS is posted to my Twitter!! Thank you so much–this is exactly what I have been searching for over the past few days!!!!

–Paul

Reply   More from author

45 Ebo Eppenga March 16, 2009 at 6:57 am

Great script! Thanks a lot! Works perfectly “out-of-the-box”.

Reply   More from author

46 Tom April 1, 2009 at 10:49 am

The script fuctions withour crashing but all I get when I executive it manually is the title of the first item of the RSS feed on my browser window under php, but nothing gets posted to twitter

is this a curl problem or something else?

Reply

47 Vitaly April 21, 2009 at 10:57 pm

Does it automatically cut the title to fit the url and still be within 140 characters?

Reply

48 mousia April 27, 2009 at 12:47 pm

Hi there,

The script works fine , no duplicates (alth0oug have run it manually so far, no cron set up yet)…

My problem is that the output is displayed as follows in twitter.

http://tinyurl.com/xxxx

Also , is there a way to display more that 1 feed at a time. i.e. to run it every hour and display 3-4 feeds at a time. More or less like in twitterfeed but without having to rely on their service and availability! :-)

Any help greatly appreciated. :-)

P.S. Ty for the script

Reply

49 mousia April 27, 2009 at 12:51 pm

Doesnt come up right in this form! :-)

Basically CDATA is literally send to twitter

….CDATA… http://tinyurl.com/

Reply

50 Editor April 29, 2009 at 8:12 am

To mousia,

Try: var $CDATA = ‘content’;

Reply   More from author

51 mousia April 29, 2009 at 11:32 am

Works like a charm :-) Its actually very handy script.

Σ’ ευχαριστω !

Reply

52 Filippo May 2, 2009 at 6:23 pm

Hello Paul,
I was wandering if you would consider updating the script for a PHP 5 and up context. Maybe even with some extra ‘parsing’ and output optimization tutorial/option. If not, would you consider consulting on it? (You can email me for that)
Thanks!

Reply   More from author

53 Yuval May 5, 2009 at 11:38 am

Great script! 2 questions:

1. How can I import more than just the last rss post (meaning more than 1)
2. Why does it come out in this format? (What is the CDATA etc.) Can I just see the title?

Thanks!

Reply   More from author

54 mousia May 5, 2009 at 12:11 pm

Hi Yuval,
Firstly I am not a coder, I just find my way around! Probably there is the “correct” way and obviously you are not a developer either if you asking that:-)

1. Yes you can. Check out pw.php and find line 18-19. You can change that so it feeds any number you want from the list of feeds! i.e. change 0 to both lines to 4 or whatever you want, to feed rss feed number 4 from the rss feeds list etc. You could also consider duplicating, or making as many copies as you want of pw.php(renamed of course), varying the numbers (and/or the rss path if you have rss feeds for multiple categories),hence setting up as many cron jobs as your pw.php(renamed) files are (so for each one of them). If you more skilled then you can just code some sort of a loop there also.

2. Try: var $CDATA = ‘content’;
This is in parse.php line 40.

Again I am not a developer, but this will do the magic.
Sorry for my english :)

Reply

55 Jake May 21, 2009 at 3:19 pm

Anyone know how to successfully use Bit.ly with authentication with this? I tried but it don’t work (bad coding).

And how can I check to stop dupe posts to stop API uses per hour all being used?

Reply

56 Adam June 8, 2009 at 2:06 am

Did anyone ever get this script working with bit.ly instead of tinyURL?

Reply

57 Jake May 21, 2009 at 3:21 pm

Also, RSS’s with apostrophes in don’t work. Do you know how to fix?

Reply

58 John June 27, 2009 at 2:07 am

Try to escape it. http://www.godaddy.com/test\’s/

Not sure if it will work but it would in C++ =)

Reply

59 Twitter Search May 26, 2009 at 9:37 pm

thats great that you are talking about the twitter api,a good example of searching with the twitter api is on twiogle.com because you can search on twitter and google at the same time.

Reply   More from author

60 Anthony K. Valley June 9, 2009 at 4:59 pm

Jake/Adam: I just ran into this code today and I’m super excited about it. I modified the script to use bit.ly instead of tinyURL.

You’ll have to supply your own bit.ly login and API. I’m also handling the special characters in the titles with urlencode($title).

Below, I left the commented out tinyURL reference in the script so everyone will know where I placed my change.

Here’s my bit.ly code:

//$tiny_url = file_get_contents(”http://tinyurl.com/api-create.php?url=” . $url);
//$status = $title . ” ” . $tiny_url;
$bit_lySource = file_get_contents(”http://api.bit.ly/shorten?version=2.0.1&longUrl=”.$url.”&login=YOUR_BIT.LY_LOGIN_NAME&apiKey=YOUR_BIT.LY_APIKEY&history=1″);
preg_match(’@”(shortUrl.*)”(.*?)”@i’,$bit_lySource, $matches);
$bit_ly = $matches[2];
$status = urlencode($title) . ” ” . $bit_ly;

I’m looking into changing the duplicates issue that I’m seeing with the code. I’ve also wrapped this into a function and created a loop so that more than one RSS feed is read and posted.

When I get the duplication resolved, I’ll post some more code. I haven’t written PHP in a long time, so expect some less-than-spectacular, but working results.

Reply   More from author

61 Paul Stamatiou June 9, 2009 at 5:02 pm

Thanks for the update Anthony! I’ll have to give that a whirl myself and update as necessary.

Reply   More from author

62 Adam June 9, 2009 at 11:20 pm

Anthony, that’s great, thanks so much.

I’ve tried it out, however I’m getting the following error when I execute tw.php

Parse error: syntax error, unexpected ‘:’ in /MY_PATH/tw.php on line 22

My line 22 has…

$bit_lySource = file_get_contents(”http://api.bit.ly/shorten?version=2.0.1&longUrl=”.$url.”&login=YOUR_BIT.LY_LOGIN_NAME&apiKey=YOUR_BIT.LY_APIKEY&history=1″);

*with my bit.ly login name and API key changed of course

Reply

63 Anthony K. Valley June 10, 2009 at 2:55 pm

Adam, that’s odd… my code doesn’t have a colon in it at all… I’ve placed a text file of this here: http://drop.io/akv_rsstotwitter/

The file is called tw_snippet.txt and it’s the same thing as what I posted. Maybe that source file will get you better results.

Reply   More from author

64 Monica June 10, 2009 at 11:31 am

Hi everyone. Sorry if this a dumb question, but I’m new to this sort of coding.

I have the script running, and it does a good job. However, the RSS feed I want to put on Twitter often uses titles that are longer than the amount of characters allowed by Twitter. How can I get the program to grab only the first, say, 120 characters of the title (allowing room for the URL at the end)?

Thanks in advance.

Reply

65 Anthony K. Valley June 10, 2009 at 2:50 pm

Monica:

Here’s a php snippet to shorten the tweet to 140 characters and an ellipsis symbol (…) between the shortened title and the url:

$status = $title . ” ” . $tiny_url;
if (strlen($status)>140) {$status = substr($title,0,136-strlen($tiny_url)) . “… ” . $tiny_url; }

I’ve also posted this update to a drop that I’ve created for these changes: http://drop.io/akv_rsstotwitter

Reply   More from author

66 Monica June 20, 2009 at 2:53 am

Thanks for your help with shortening the URLs!

Has anyone been able to modify this to use it with Atom feeds? Seems like LastRSS will not process them, or at least the one I’m trying to use.

Reply

67 Fábio June 14, 2009 at 11:21 pm

Thanks the script full job.

Reply   More from author

68 Ado June 26, 2009 at 9:33 am

I still don’t get it… How to post all 10 items from feed to twitter? What ever i try to change it gives me errors, and unchanged version tweet only 1 latest item from feed even with var $items_limit = 10; Any help PLEASE!!!

Reply   More from author

69 John June 27, 2009 at 2:06 am

Any Ideas?

Reply

70 monica June 27, 2009 at 12:22 pm

Ado,

I’ve rewritten the script to use SimplePie instead of LastRSS (to solve my Atom feed problem) and the one I’ve written will also post multiple items. I don’t have the code with me at home, but when I return to work I’ll post it. But if you spend some time using SimplePie, you could probably figure it out.

Reply

71 Ado June 29, 2009 at 3:32 am

well i can try it (probably) easy with magpie as i use it frequently but i thought someone had solved this problem within this code… Thanks anyway.

Reply   More from author

72 Ado July 1, 2009 at 9:17 am

Monica can you please send me your code, i couldn’t make it working right with magpie as it making problems with special characters :s

Reply   More from author

73 Ado July 1, 2009 at 10:56 am

WOW… Finally i fixed current code to post all rss items to twitter :))) If anyone is interested to have it, please let me know here!!! I will just test it next few hours.

Reply   More from author

74 jimitz July 2, 2009 at 7:13 am

Hi folks,
I have a problem with the script, it outputs this: Error: RSS file not found, dude.

I set up a feedburner feed, but it doesnt work… any ideas?
thx a lot

Reply

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post: Sidebar Creative Launches

Next post: The Vista Challenge