Skip to content

Instantly share code, notes, and snippets.

@byronrode
Created May 17, 2011 08:10
Show Gist options
  • Save byronrode/976138 to your computer and use it in GitHub Desktop.
Save byronrode/976138 to your computer and use it in GitHub Desktop.
Twitter Intents over SSL

Serving Twitter's JS for Intents or Tweet Button's is a pain when it comes to SSL as Twitter has no SSL Cert installed on their serving subdomain. To get around this, without having to manually maintain the JS, I came up with the following workaround.

Create a file called twitter.platform.js.php in your JS Folder and paste the following:

<?php
header('Content-type: text/javascript'); 
echo file_get_contents('http://platform.twitter.com/widgets.js');
?>

Then, in your index file where you are calling the Twitter JS, replace the Script tags with the following:

<script type="text/javascript" src="/location/to/js/twitter.platform.js.php"></script>

The above code will pull Twitter's non-secure JS from their server and render the output as JavaScript and allow you to # serve it over SSL without the warnings, as it will originate from your site.**

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment