Ejemplo n.º 1
0
 public function authorization()
 {
     if (OAuthRequestVerifier::requestIsSigned()) {
         try {
             $req = new OAuthRequestVerifier();
             $user_id = $req->verify();
             // If we have an user_id, then login as that user (for this request)
             if ($user_id) {
                 self::setUid($user_id);
                 //这是 oauth 访问
                 self::$_oauth = true;
                 // **** Add your own code here ****
             }
         } catch (OAuthException $e) {
             $msg = $e->getMessage();
             throw new CHttpException(401, $msg);
             exit;
         }
     } else {
         $msg = "Can't verify request, missing oauth_consumer_key or oauth_token";
         throw new CHttpException(401, $msg);
         exit;
     }
 }
Ejemplo n.º 2
0
 public function authorization()
 {
     //        $data = $_REQUEST;
     //        $data = OAuthRequestLogger::getAllHeaders();
     //        $data = $_SERVER;
     //        $data = $_ENV;
     //        $headers = array_merge($_ENV, $_SERVER);
     //        $retarr = array();
     //        foreach ($headers as $key => $val) {
     //				//we need this header
     //				if (strpos(strtolower($key), 'content-type') !== FALSE)
     //					continue;
     //				if (strtoupper(substr($key, 0, 5)) != "HTTP_")
     //					unset($headers[$key]);
     //					$headers[$key] = 'xxxxxxxxxxxxxxxxx';
     //			}
     //        Normalize this array to Cased-Like-This structure.
     //		foreach ($headers AS $key => $value) {
     //			$key = preg_replace('/^HTTP_/i', '', $key);
     //			$key = str_replace(
     //					" ",
     //					"-",
     //					ucwords(strtolower(str_replace(array("-", "_"), " ", $key)))
     //				);
     //			$retarr[$key] = $value;
     //		}
     //		ksort($retarr);
     //        self::d($data);
     //        exit();
     if (OAuthRequestVerifier::requestIsSigned()) {
         //            $data = $_SERVER;
         //            self::d($data);
         //            exit();
         try {
             $req = new OAuthRequestVerifier();
             $user_id = $req->verify();
             // If we have an user_id, then login as that user (for this request)
             if ($user_id) {
                 self::setUid($user_id);
                 //This is oauth Access
                 self::$_oauth = true;
                 // **** Add your own code here ****
             } else {
             }
         } catch (OAuthException $e) {
             $msg = $e->getMessage();
             throw new CHttpException(401, $msg);
             exit;
         }
     } else {
         //            $data = $_REQUEST;
         //            $data = OAuthRequestLogger::getAllHeaders();
         //            $data = $_SERVER;
         //            self::d($data);
         //            exit();
         $msg = "Can't verify request, missing oauth_consumer_key or oauth_token";
         throw new CHttpException(401, $msg);
         exit;
     }
 }