Why isn’t Twitter charging for their API?

It feels like Twitter’s general attitude towards API developers has increasingly become one of annoyance. The reason the API has become such a pain to Twitter is because they’re just giving it away.

Why aren’t they charging tiered pricing based on required access? The API is already rate limited, they just need to adjust the rates based on the payment. Instead they’ve resold the Firehose via Gnip and DataShift, which they could be selling directly. And the rest of the API they’re resentfully giving away for free.

As a developer of the Twitter API, I don’t want to be resented, I want to be respected as a consumer of their product! Let me pay for access!

I’m talking $19, $99, $299, $999, $9999, “call us” style plans here. They could charge the whole developer market. Instead, they’re putting all their hopes in “Twitter stream advertising.” They have an extremely large potential revenue stream that they’re basically just giving away for free, and they’re giving off a vibe that they’re annoyed by the developers that use it.

Check if a Javascript function exists, if so call it.

I had a little trouble searching for this on Google. So here’s a little Javascript gem for you.

If you want to call a Javascript function, but only if it exists, here’s one way you can do that.

function ifFnExistsCallIt(fnName)
   fn = window[fnName];
   fnExists = typeof fn === 'function';

I use “fn” as a variable name inplace of the word “function,” since “function” is a reserved word in Javascript.

How to save a string to S3 using PHP

I recently used Elance to commission the creation of a PHP function that takes a string as input, creates a text file, saves it to S3, and finally returns the URL to the text file.

I’m using this function to create a virtual cookie that essentially gives me infinite storage. It’s pretty darn useful. Rather than bogart this nifty function I’m giving it to you dear Internet comrade. Enjoy! 🙂

This function requires the Amazon Web Services SDK for PHP.

Tweet Button Shows 0 Fix

Twitter has a fancy widget/button called the Tweet Button that allows your readers to click a button to tweet about your webpage. It includes a count of how many people have tweeted about your page, similar to Facebook’s “like” button.

If your tweet button count seems to be stuck at zero try adding the data-counturl field. Its value should be the URL of the page you want the button to count (most likely the same value as your data-url field). Your tweet button code should look something like this:

<script src="http://platform.twitter.com/widgets.js" type="text/javascript"> </script>
<a href="http://twitter.com/share" class="twitter-share-button"
data-text="Who are you following that's not following you back? Find out here:"
data-related="DustyReagan:Creator of Friend or Follow,Cesart:Designer of Friend or Follow"

This example above is obviously for FriendOrFollow.com. Just swap out the details with your own site or page.

How to reference Smarty variables inside {php} tags

I gotta’ be honest, I’ve never used the Smarty Template Engine before in my life. I’m currently working on a project to integrate WordPress and JobberBase so they use the same WordPress theme. JobberBase uses Smarty, so I’m getting a crash course.

You can use PHP in the template (.tpl) files and reference the values of the assigned Smarty template variables like this:

  $html_title = $this->_tpl_vars['html_title'];
  $echo $html_title;

I’m sure Smarty users cringe at this sort of thing, being that it adds business logic to the template files. But, this is just the functionality I need to hack the JobberBase templates without mucking around in core JobberBase code.

I found this solution in the Smarty FAQ after hours of Googling.