Menu

Colin Devroe

Reverse Engineer. Blogger.

JSON Feed to Twitter using PHP

In 2009 I scrawled together a simple PHP script that tweeted links based on an RSS feed. I then updated it to support OAuth and open sourced it on GitHub.

I haven’t really touched it since (though I get about 3 emails a month about it). Just a small update here and there.

This morning, with all of the JSON Feed hubbub going on, I decided to recreate that same simple script to parse JSON Feed rather than RSS. I also updated to the latest release of the PHP Twitter OAuth class by Tijs Verkoyen.

You can download the latest release or clone the repository on GitHub.

This took me mere minutes thanks to JSON Feed being much easier to deal with.

Disappearing apps and services

Alexei Baboulevitch (archagon) in a comment on Hacker News:

These indie apps are often marketed as beautiful, wholesome alternatives to grimy corporate or open source software, but how could I possibly rely on these products for essential tasks like note-taking if they’re just going to disappear out from under me in a few years? The idea that software has a lifespan controlled by the developer is, in my opinion, toxic to the market. It’s just one of the many things pulling the App Store down, and one of the many downsides of living in a walled garden.

I have to agree. More and more I’m inclined to use an open (but not necessarily free) alternative for just about any app or service that I rely on.

I wasn’t a Vesper user, but if I was, I’d be scrambling to find an alternative since it is now being shut down. I’m a happy Simplenote user which is free and open and backed by a company that wants to keep things open and running for as long as possible.

Picturelife’s recent closing, which I called in January of 2015, is also a stark reminder that even if we rely heavily on an app or service, and even if we support it with our money and our word-of-mouth, it doesn’t mean that it will stick around.

If you find yourself relying on an app or service that could disappear tomorrow do yourself a favor and seek out alternatives while you still have plenty of time to make the switch. You don’t have to switch, but knowing what alternatives are out there and having a plan can save you a ton of headaches. If I hadn’t switched from Picturelife to iCloud when I did I’d be hurting right now. Bigtime.

I’ll have more on Picturelife’s shutdown in a future post.

How can I get into programming?

Linus Torvalds in 2004 on the Linux Kernel Mailing List (LKML):

To me, the biggest thing with small patches is not necessarily the patch
itself. I think that much more important than the patch is the fact that
people get used to the notion that they can change the kernel – not just
on an intellectual level (“I understand that the GPL means that I have the
right to change my kernel”), but on a more practical level (“Hey, I did
that small change”).

Over the years I’ve been asked many times “how can I get into programming?” and my answer has always been to contribute to some open source code. The benefits are manifold.

  • Sense of accomplishment (like Linus brought out)
  • Exposure to someone else’s code (you can learn a lot this way)
  • Helps you get comfortable with criticism (esp. if the codebase is managed by several people)
  • Learn to collaborate (have a team before you have a team)
  • Give yourself some publicity (the number 1 way to get work is to show your work)

So, get in there and get started.

GoPro open sources Camera Toolkit

GoPro just updated their iOS app. In the release notes I noticed a link to their developer page wherein they’ve open sourced their Camera Toolkit for iOS and Android. Let’s hope a ton of bug fixes result so I can stop hacking mine.

Microsoft open sources .NET Core

Richard Lander on the .NET Blog:

We are excited to announce the release of .NET Core 1.0, ASP.NET Core 1.0 and Entity Framework Core 1.0, available on Windows, OS X and Linux! .NET Core is a cross-platform, open source, and modular .NET platform for creating modern web apps, microservices, libraries and console applications.

They said they would, and they did. Good on MSFT. Likely an incredible amount of work to get this out. And supposedly this is also a deep rewrite of .NET Core.

Google has JAVA (though, they didn’t make it), Apple has Swift, and now MSFT has .NET*. All fully open source languages, frameworks, and platforms backed by public companies. A good time to be a programmer.

* MSFT has had .NET forever, it is just that now it is open sourced.

RSS to Twitter using PHP

Update January 19, 2010: This script is now available on GitHub. Go forth and fork.

Today I noticed that my now ancient PHP script to update Twitter automatically using PHP/cron needed to be updated. It turns out that Twitter stopped recognizing URLs with ? in them as clickable links. Here is an example tweet where you’ll notice this happening.

I could have told Twitter and asked that they update the way they handle URLs but in reality my script was old, slow, too long, and shouldn’t include ? anyway so I figured I’d write a new one from scratch that included my short URL scheme.

So, here is the PHP script to parse an RSS feed and send the posts to Twitter. It includes a caching mechanism so that you won’t have duplicate URLs posted to Twitter. If you want it, take it. However, if you are better than I am at PHP (most 6yr. olds are better than I am at programming) then I ask that you fork the script on Gist and try to improve it.

Update Dec. 6 @ 5:34p: Kyle Slattery, follow Viddler team member, loves him some Ruby on Rails. As such he’s offered up this version of the script rewritten in Ruby.

Next up we have Anthony Sterling, self-proclaimed “PHP addict”, who has rewritten the script to make the configuration a bit easier. He also changed the way the cache is saved. He’s using a hashed version of the title for each post as his key. I do not believe this to be the best way to go, since post titles can easily change after publishing – but I do like that the script is about 20 lines shorter and the code is arguably cleaner.

Thanks to both Kyle and Anthony for their versions. Lets keep this going and see if we can get this script much more succinct, stable, faster, and usable by others?