Ejemplo n.º 1
0
 function request($command, $args = array())
 {
     // NOTE: cache not implemented
     $args = array_merge(array("url" => $this->rest_endpoint, "method" => $command, "format" => "json", "nojsoncallback" => "1"), $args);
     $request = new OAuthRequest(Verb::POST, $args['url']);
     foreach ($args as $key => $value) {
         $request->addBodyParameter($key, $value);
     }
     $this->oauth_service->signRequest($this->token, $request);
     $response_object = $request->send();
     $response = $response_object->getBody();
     $this->parsed_response = json_decode($response, TRUE);
     if ($this->parsed_response['stat'] == 'fail') {
         if ($this->die_on_error) {
             die("The Flickr API returned the following error: #{$this->parsed_response['code']} - {$this->parsed_response['message']}");
         } else {
             $this->error_code = $this->parsed_response['code'];
             $this->error_msg = $this->parsed_response['message'];
             $this->parsed_response = false;
         }
     } else {
         $this->error_code = false;
         $this->error_msg = false;
     }
     return $response;
 }