getResponseBody() 공개 메소드

Get the Response body
public getResponseBody ( ) : string
리턴 string page
예제 #1
0
 /**
  * Save the photo to disk
  * @param string path where to store the file
  * @param optional boolean thumb get the thumbnail (100x140, default) or the
  *        bigger variant (400x600 - FALSE)
  * @return boolean success
  * @see IMDB person page / (Main page)
  */
 public function savephoto($path, $thumb = TRUE, $rerun = FALSE)
 {
     $photo_url = $this->photo($thumb);
     if (!$photo_url) {
         return FALSE;
     }
     $req = new Request($photo_url, $this->config);
     $req->sendRequest();
     if (strpos($req->getResponseHeader("Content-Type"), 'image/jpeg') === 0 || strpos($req->getResponseHeader("Content-Type"), 'image/gif') === 0 || strpos($req->getResponseHeader("Content-Type"), 'image/bmp') === 0) {
         $fp = $req->getResponseBody();
     } else {
         if ($rerun) {
             $this->debug_scalar("<BR>*photoerror* at " . __FILE__ . " line " . __LINE__ . ": " . $photo_url . ": Content Type is '" . $req->getResponseHeader("Content-Type") . "'<BR>");
             return FALSE;
         } else {
             $this->debug_scalar("<BR>Initiate second run for photo '{$path}'<BR>");
             return $this->savephoto($path, $thumb, TRUE);
         }
     }
     $fp2 = fopen($path, "w");
     if (!$fp || !$fp2) {
         $this->debug_scalar("image error...<BR>");
         return false;
     }
     fputs($fp2, $fp);
     return TRUE;
 }
예제 #2
0
파일: Title.php 프로젝트: tboothman/imdbphp
 /**
  * Save the poster/cover image to disk
  * @param string $path where to store the file
  * @param boolean $thumb get the thumbnail (100x140, default) or the
  *        bigger variant (400x600 - FALSE)
  * @return boolean success
  * @see IMDB page / (TitlePage)
  */
 public function savephoto($path, $thumb = true)
 {
     $photo_url = $this->photo($thumb);
     if (!$photo_url) {
         return false;
     }
     $req = new Request($photo_url, $this->config);
     $req->sendRequest();
     if (strpos($req->getResponseHeader("Content-Type"), 'image/jpeg') === 0 || strpos($req->getResponseHeader("Content-Type"), 'image/gif') === 0 || strpos($req->getResponseHeader("Content-Type"), 'image/bmp') === 0) {
         $image = $req->getResponseBody();
     } else {
         $ctype = $req->getResponseHeader("Content-Type");
         $this->debug_scalar("*photoerror* at " . __FILE__ . " line " . __LINE__ . ": " . $photo_url . ": Content Type is '{$ctype}'");
         if (substr($ctype, 0, 4) == 'text') {
             $this->debug_scalar("Details: <PRE>" . $req->getResponseBody() . "</PRE>\n");
         }
         return false;
     }
     $fp2 = fopen($path, "w");
     if (!$fp2) {
         $this->logger->warning("Failed to open [{$path}] for writing  at " . __FILE__ . " line " . __LINE__ . "...<BR>");
         return false;
     }
     fputs($fp2, $image);
     return true;
 }