Tag Archives: OAuth

Update To The YOURLS – Twitter – Google Reader Script

I recently blogged, Using YOURLS And The Twitter API With Google Reader’s Custom SendTo Link. Since then, I have made a few improvements to the script, mostly in the error-trapping line.

  • I broke out the variables for the YOURLS API signature, plus the Twitter API consumer key, consumer secret, access key and access secret, and converted them to constants.
  • I removed urldecode() from the formation of the YOURLS API request. It’s not necessary.
  • I have added code to trap any errors in when making the short URL.
    • I am now getting the statusCode and message node contents, in case something goes wrong with the shortening.
    • I set the script to die on a URL shortening error, which is determined by the short URL being an empty string or the statusCode node having a value other than 200.
    • The code, coupled with the message, should explain any problems adequately enough to debug shortening issues. If you find you are getting zero-length responses from your URL shortening, that’s probably due to a server misconfiguration; possibly from bad mod_rewrite rules, possibly due to a messed-up cookie on your PC.
  • I strip HTML tags from the title.
    • I discovered today that some Google Reader items will have HTML markup in their titles, such as <em>.
  • I check for failure in the Twitter API request.
    • TwitterOAuth will return Boolean false if it could not complete its curl request to the API, and will return an XML document in any other case, including failure of the tweet to go through.
    • If the cUrl request is good but the tweet doesn’t go through, Twitter responds with an HTTP status code other than 200. We can capture the last status code returned by our request, test it, and print the XML response describing what happened.

Continue reading

Using YOURLS And The Twitter API With Google Reader’s Custom SendTo Link

Update, January 3, 2011: There is a revision of this script at http://www.dougv.com/2011/01/03/update-to-the-yourls-twitter-google-reader-script/.

I love me some Google Reader. As I noted in the past, now that I understand it, I don’t know how I ever managed to get by without it.

One of my favorite Reader features is the ability to send a link of the content to several social media sources, such as Facebook, Twitter, Digg, Reddit and more. Even better, you can create a custom link to which you’d like to send Reader items.

I use a custom install of YOURLS to shorten links, in part because there have been some scares surrounding the long-term viability of many online link shorteners; in part, because I don’t like trusting that these link-shortening services won’t hijack my links, employ interstitial ads or do bad things with the data they collect; and in part because I want to see link-click statistics myself, including the underlying data.

Thanks to the custom link option in Reader, coupled with the Twitter API, I’ve come up with a PHP script that effectively replaces the built-in Twitter send to link in Reader, allowing me to use my install of YOURLS and to post automatically. (The Reader send to Twitter link actually opens the Twitter home page, pasting the title and Google-shortened link into the status tweeting box at the top of the page.)

Continue reading

On Facebook’s New Features, Privacy And The Near Future Of The Web

Quite a bit has been made recently of the changes to Facebook’s default settings, an extensive expansion of how Facebook shares data with other Web sites, and how all that works within the traditional expectation — if not the fundamental understanding — most people have about privacy.

Facebook’s recent change to, by default, share public user information with partner Web sites — namely, Microsoft’s Docs.com, Internet radio provider Pandora and city-based business review site Yelp — is “building a largely closed, alternative version of the Internet,” or, in plainer language, “a power grab.”

This argument is further (and ironically) strengthened by Facebook’s announcement at the recent f8 developer conference that it is switching from its proprietary Facebook Connect login system to OAuth, the soon-to-be-a-standard, open Web site authentication protocol. In so doing, the fabled idea of the “single sign-on” for all Web sites becomes less pipe dream and more within reach — with Facebook the linchpin, and by inference, the one link that can’t be removed from the chain.

In other words, Facebook is a 1998-vintage AOL that doesn’t suck.

That’s not a bad thing. Actually, it’s a great thing.
Continue reading