Plugin Directory

Changeset 194644


Ignore:
Timestamp:
01/16/2010 11:48:00 PM (16 years ago)
Author:
hanok
Message:

Version 0.2 alternativa a cURL

Location:
googl-generator/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • googl-generator/trunk/googl-generator.php

    r194567 r194644  
    44Plugin URI: http://www.dolcebita.com/wordpress/googl-generator/
    55Description: Returns short URL based on Goo.gl using Matthew Flaschen web service.
    6 Version: 0.1
     6Version: 0.2
    77Author: Marcos Esperon
    88Author URI: http://www.dolcebita.com/
     
    2626
    2727function googl_generator($long_url) {
    28     $output = '';
     28   
     29  $output = '';
     30 
    2931  if (extension_loaded("curl")) {
     32 
    3033    $curl = curl_init("http://ggl-shortener.appspot.com/?url=" . rawurlencode($long_url));
    3134    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    3235    $response_text = curl_exec($curl);
    3336    if($response_text) {
    34     $json_response = json_decode($response_text);
    35     /*if($error = ($json_response->error_message))
    36       throw new Exception("Gateway returned error: " . $error);*/
     37      $json_response = json_decode($response_text);
    3738    }
    3839    $output = $json_response->short_url;
     40 
     41  } else {
     42 
     43    $url = htmlentities($long_url, ENT_QUOTES);
     44      $obj = json_decode(file_get_contents('http://ggl-shortener.appspot.com/?url=' . urlencode($url)));
     45      $output = $obj->{'short_url'};
     46
    3947  }
     48 
    4049  echo $output;
     50 
    4151}
    4252
  • googl-generator/trunk/readme.txt

    r194571 r194644  
    66Stable tag: 0.1
    77 
    8 Returns short URL based on Goo.gl using Matthew Flaschen web service. cURL PHP extension must be enabled in your server.
     8Returns short URL based on Goo.gl using Matthew Flaschen web service.
    99
    1010== Description ==
     
    3232== Changelog == 
    3333
     34= 0.2 = 
     35* Alternative method without cURL extension.
     36
    3437= 0.1 = 
    3538* Initial release.
Note: See TracChangeset for help on using the changeset viewer.