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

Your ur1 is: (.+)<\/a><\/p>/', $result, $match );

f86febf
+if (!empty($match))
f86febf
+    die($match[1]);
f86febf
 else
f86febf
-{
f86febf
     die("ERROR");
f86febf
-}
f86febf
+
f86febf
 
f86febf
 ?>