]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/urlshortenerplugin2.php
Introduced common_location_shared() to check if location sharing is always,
[quix0rs-gnu-social.git] / lib / urlshortenerplugin2.php
index 9474477776c3d11b6897f046759a11c00c627325..cb11b12ec1fbc92b0aa9c2ef3a94446a9a96ad1d 100644 (file)
@@ -22,11 +22,11 @@ error_reporting(E_ALL );
  *
  * @category Plugin
  * @package  StatusNet
- * @author   Leon Giesenkaemper <leon@darksider3.de>
+ * @author   Craig Andrews <candrews@integralblue.com>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link     http://darksider3.de/sn/urlshortenerplugin2.html
+ * @link     http://gnu.io
  */
-define("STATUSNET", 1); //for manual debugging.
+define("STATUSNET", 1);
 if (!defined('STATUSNET') && !defined('LACONICA')) {
     exit(1);
 }
@@ -37,9 +37,9 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
  *
  * @category Exception
  * @package StatusNet
- * @author   Leon Giesenkaemper <leon@darksider3.de>
+ * @author   Craig Andrews <candrews@integralblue.com>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link     http://darksider3.de/sn/urlshortenerplugin2.html#exceptions
+ * @link     http://gnu.io
  */
 class PluginErrorException extends Exception {
     protected $severity=0;
@@ -83,7 +83,6 @@ class PluginErrorException extends Exception {
 function exception_error_handler($errno, $errstr, $errfile, $errline ) {
     throw new PluginErrorException($errstr, 0, $errno, $errfile, $errline);
 }
-set_error_handler("exception_error_handler", E_ALL);
 
 /* the Exceptionhandler for Syntax-Errors, throwed by PHP itself */
 /**
@@ -91,7 +90,7 @@ set_error_handler("exception_error_handler", E_ALL);
  *
  * @category Plugin
  * @package  StatusNet
- * @author   Leon Giesenkaemper <leon@darksider3.de>
+ * @author   Craig Andrews <candrews@integralblue.com>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://darksider3.de/sn/urlshortenerplugin2.html
  */
@@ -124,12 +123,8 @@ abstract class UrlShortenerPlugin2
   {
     try
     {
-      //Or create exception here, by looking for 'false'...? Hmm..
-      //No, let HTTPClient throw it. But then we need a more generally
-      //Exception system.
       $request  = HTTPClient::start();
       $response = $request->get($url);
-
     } catch(PluginErrorException $e)
     {
       $e->printFull();
@@ -145,19 +140,12 @@ abstract class UrlShortenerPlugin2
   *
   * @return string response body
   *
-  * @todo self with exceptions as in httpGet()
   */
   protected function httpPost($url, $data)
   {
-    try{
-      $request  = HTTPClient::start();
-      $response = $request->post($url, null, $data);
-
-    } catch(PluginErrorException $e)
-    {
-      $e->printFull();
-      return false;
-    }
+    
+    $request  = HTTPClient::start();
+    $response = $request->post($url, null, $data);
     return $response->getBody();
   }
   // Hook handlers
@@ -212,7 +200,6 @@ abstract class UrlShortenerPlugin2
       {
         $shortenedUrl = $result;
         //dont create an exception, so we can do that without.
-        //If needed, i can code done..but actually it seems useless to do that.
         common_log(LOG_INFO,
                    __CLASS__ . ": $this->shortenerName ".
                    "shortened $url to $shortenedUrl");
@@ -222,18 +209,4 @@ abstract class UrlShortenerPlugin2
     return true;
   }
 }
-//@debug
-function A() {
-    $foo->bar(); // Purposely cause error
-}
-
-function B($c) {
-    A();
-}
-
-try {
-    B('foobar');
-} catch (PluginErrorException $e) {
-    echo $e->printFull();
-}
 ?>