예제 #1
0
 /**
  * Upload an image using a URL to a remote image that Imgur will read.
  * @param string $url
  * @return Imgur_Image Or throws an exception on failure.
  **/
 public function uploadImageFromURL($url)
 {
     $json = $this->uploadImage($url, 'url');
     Imgur::checkError($json);
     $img = new Imgur_Image();
     return $img->loadFromJSON($json['upload']);
 }
예제 #2
0
 public function load()
 {
     $data = Imgur::sendGET($this->getURL());
     $json = json_decode($data, true);
     Imgur::checkError($json);
     $class = $this->getImageClass();
     foreach ($json['images'] as $image) {
         $img = new $class();
         $img->loadFromJSON($image);
         $this[$img->hash] = $img;
     }
 }
예제 #3
0
 /**
  * Get the count of images in this account
  * @return int
  **/
 public function getImageCount()
 {
     return -1;
     // This currently returns a 404.  Huh.
     $data = Imgur::sendGET(Imgur::$api_url, '/account/images_count');
     var_export($data);
     $json = json_decode($data, true);
     Imgur::checkError($json);
     if (array_key_exists('images_count', $json)) {
         return (int) $json['images_count']['count'];
     }
 }
예제 #4
0
 /**
  * Nuke it from orbit.  It's the only way to be sure.
  * @return bool Or throws an exception on failure.
  **/
 public function delete()
 {
     if (!$this->deletehash) {
         return false;
     }
     $json = json_decode(Imgur::sendGET(Imgur::$api_url . '/delete/' . $this->deletehash, array('_method' => 'delete')), true);
     Imgur::checkError($json);
     return $json['delete']['message'] == 'Success';
 }