|  Register

Google URL Shortener for Tweetdeck

by brett hale in Social Media

The longest part of this process will be going to http://code.google.com/apis/console/ and signing up for your api key. Once you have that secured, you can use that in the code below. The only other change needed is to add your user id. I use the user id as a simple authentication for the shortener as an added measure. You will use the same id in the url entered in the TweetDeck options and the code below.

Once you've made your adjustments, save the code as googl.php in your root folder, you can begin using a similar url to the on below to return your short url. You can really place it and name it where ever and whatever you would like, just make the necessary adjustments.


TweetDeck Custom URL Shortener Options

ini_set('display_errors', '1');
$lu = htmlspecialchars_decode($_REQUEST['lu']);
$gep = 'https://www.googleapis.com/urlshortener/v1';
$gaurl = $gep.'/url?key='.$gak;

function shortUrl($url,$longUrl){

        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $requestData = array('longUrl' => $longUrl);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestData));
        $result = curl_exec($ch);
        return $result;
//You can remove the if statement to remove the id check in the url
if($_REQUEST['user']==='INSERT_USER_ID') {
    $rwurl = json_decode(shortUrl($gaurl,$lu));
    echo htmlspecialchars($rwurl->id);



There are no comments

Post a comment

  • Top ↑
  • ©2019 StraightFromHale.com. All Rights Reserved.