Beispiel #1
0
 function testExecuteMethod_ThrowsExceptionWhenThrowOnErrorSpecified()
 {
     $api = new Phlickr_Api('INVALID_KEY_FOR_TESTING', 'INVALID_SECRET');
     try {
         $api->executeMethod('flickr.test.echo', array());
     } catch (Phlickr_Exception $ex) {
         $this->assertEquals('Invalid API Key (Key not found)', $ex->getMessage());
         $this->assertEquals(100, $ex->getCode());
         return;
     } catch (Exception $ex) {
         $this->fail('threw the wrong type (' . get_class($ex) . ') of exception.');
     }
     $this->Fail('An exception should have been thrown.');
 }
Beispiel #2
0
 private function checkTicket($ticketsId, $type)
 {
     $return = ["status" => self::UPLOAD_STATE_FAILED, "dist_id" => null];
     $response = $this->_api->executeMethod("flickr.photos.upload.checkTickets", ["tickets" => $ticketsId]);
     if (!$response->isOk()) {
         throw new Bridge_Exception_ApiConnectorRequestFailed('Unable to retrieve element list ' . $type);
     }
     $xml = $response->getXml();
     $complete = isset($xml->uploader->ticket["complete"]) ? (string) $xml->uploader->ticket["complete"] : null;
     if ($complete) {
         if ((int) $complete == 0) {
             $return["status"] = self::UPLOAD_STATE_NOT_COMPLETED;
         } elseif ((int) $complete == 2) {
             $return["status"] = self::UPLOAD_STATE_FAILED_CONVERTING;
         } else {
             $return["dist_id"] = (string) $xml->uploader->ticket["photoid"];
             $return["status"] = self::UPLOAD_STATE_DONE;
         }
     }
     return $return;
 }
Beispiel #3
0
 /**
  * Find a user based on their Flickr URL.
  *
  * The URL can be in the following forms:
  * - http://flickr.com/photos/39059360@N00/
  * - http://flickr.com/photos/justtesting/
  * - http://flickr.com/people/39059360@N00/
  * - http://flickr.com/people/justtesting/
  *
  * This will thrown an Phlickr_MethodFailureException exception if no user
  * can be found.
  *
  * @param   object Phlickr_Api $api An API object.
  * @param   string $user The user's URL.
  * @return  object Flickr_User
  * @since   0.1.7
  * @see     findByUsername(), findByEmail()
  */
 static function findByUrl(Phlickr_Api $api, $url)
 {
     $resp = $api->executeMethod('flickr.urls.lookupUser', array('url' => $url));
     $id = (string) $resp->xml->user['id'];
     return new Phlickr_User($api, $id);
 }
Beispiel #4
0
 /**
  * Find a group based on its Flickr URL.
  *
  * The URL can be in the following forms:
  * - http://flickr.com/groups/infrastructure/
  * - http://flickr.com/groups/infrastructure/pool/
  * - http://flickr.com/groups/97544914@N00/
  *
  * This will thrown an Phlickr_MethodFailureException exception if no group
  * can be found.
  *
  * @param   object Phlickr_Api An API object.
  * @param   string The groups's URL.
  * @return  object Flickr_User
  * @since   0.1.8
  */
 static function findByUrl(Phlickr_Api $api, $url)
 {
     $resp = $api->executeMethod('flickr.urls.lookupGroup', array('url' => $url));
     $id = (string) $resp->xml->{self::XML_RESPONSE_ELEMENT}['id'];
     return new Phlickr_Group($api, $id);
 }