diff -ru sticky-notes-0.4.unbundled/shorten.php sticky-notes-0.4.url-short-patch/shorten.php --- sticky-notes-0.4.unbundled/shorten.php 2013-07-12 20:12:48.000000000 +0100 +++ sticky-notes-0.4.url-short-patch/shorten.php 2013-07-13 07:11:00.025153764 +0100 @@ -5,6 +5,7 @@ * @license BSD License - www.opensource.org/licenses/bsd-license.php * * Copyright (c) 2013 Sayak Banerjee +* Copyright (c) 2013 Athmane Madjoudj * All rights reserved. Do not remove this copyright notice. */ @@ -15,15 +16,9 @@ $paste_id = $core->variable('id', ''); $project = $core->variable('project', ''); $hash = $core->variable('hash', 0); -$api_url = "https://www.googleapis.com/urlshortener/v1/url?key={$config->google_api_key}"; +$api_url = "http://ur1.ca/"; $is_key = false; -// We need the google API key for this to work -if (empty($config->google_api_key)) -{ - die("ERROR"); -} - // Prepare the paste ID for use if (!empty($paste_id)) { @@ -88,32 +83,19 @@ // Now that we know the paste exists, generate the paste URL $paste_url = $nav->get_paste($row['id'], $row['urlkey'], $hash, $project); - // Create cURL $ch = curl_init(); -curl_setopt($ch, CURLOPT_URL, $api_url); -curl_setopt($ch, CURLOPT_POST, true); -curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array("longUrl" => $paste_url))); -curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); +curl_setopt($ch, CURLOPT_URL,"http://ur1.ca/"); +curl_setopt($ch, CURLOPT_POST, 1); +curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('longurl' => $paste_url))); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - -// Execute the post $result = curl_exec($ch); - -// Close the connection curl_close($ch); - -// Parse the response -$response = json_decode($result, true); - -if (isset($response['id'])) -{ - die($response['id']); -} +preg_match( '/

Your ur1 is: (.+)<\/a><\/p>/', $result, $match ); +if (!empty($match)) + die($match[1]); else -{ die("ERROR"); -} + ?>