Esempio n. 1
0
 /**
  * Suck an HTTP adapter out of an OAuth instance
  * @param object $oauth
  **/
 public static function setOAuth($oauth)
 {
     // We support the following adapters officially:
     // PEAR's HTTP_OAuth_Consumer
     // Zend's Zend_Oauth_Consumer
     // The PECL extension "OAuth"
     // For all other objects, we'll strip underscores.
     // Let's say we have a custom OAuth class called My_Super_OAuth_Thing
     // We'll then look for "Imgur_HTTPAdapter_OAuth_MySuperOAuthThing"
     $adapter_class = '';
     if (extension_loaded('oauth') && $oauth instanceof OAuth) {
         $adapter_class = 'PECLOAuth';
     } else {
         $adapter_class = str_replace('_', '', get_class($oauth));
     }
     $adapter_class = 'Imgur_HTTPAdapter_OAuth_' . $adapter_class;
     $adapter = $adapter_class::createByWrapping($oauth);
     self::setHTTPAdapter($adapter);
     self::$has_oauth = true;
 }