Esempio n. 1
0
    static function common_authorization_header_test($user_data, $correct_base64_signature)
    {
        $s = new MySpaceAPI(UnitTests::$UTF8_CONSUMER_KEY, UnitTests::$UTF8_CONSUMER_SECRET);
        $oauth_nonce = 'd8502726b041db1758892edee8826314';
        $oauth_timestamp = '1235879978';
        $output = $s->get_signed_request('PUT', 'v1/users/85628343/appdata.XML', $user_data, $oauth_nonce, $oauth_timestamp);
        $auth = MySpaceAPI::get_request_authorization_header('v1/users/85628343/appdata.XML', $output);
        $correct_auth = <<<AUTH
Authorization: OAuth realm="http://api.myspace.com/v1/users/85628343/appdata.XML" oauth_consumer_key="http%3A%2F%2Fwww.myspace.com%2F457168699" oauth_token="" oauth_nonce="d8502726b041db1758892edee8826314" oauth_timestamp="1235879978" oauth_signature_method="HMAC-SHA1" oauth_version="1.0" oauth_signature="{$correct_base64_signature}"
AUTH;
        return $auth == $correct_auth;
    }
Esempio n. 2
0
 private function get($path, $get_args = NULL)
 {
     if (!$get_args) {
         $get_args = array();
     }
     $auth = MySpaceAPI::get_oauth_uri_part($path, 'GET', $get_args);
     // The auth string will only contain oauth stuff, the args given to it are
     // only for the purposes of creating the signature. To get the get args
     // included, we still need to append them explicitly.
     $url = MySpaceAPI::$SERVER . '/' . $path;
     if (count($get_args) > 0) {
         $query = http_build_query($get_args, '', '&');
         $url .= '?' . $query . '&' . $auth;
     } else {
         $url .= '?' . $auth;
     }
     return MySpaceAPI::curl_get($url, $this->curl_verbose);
 }