The Http class is under the directory ThinkPHP/Lib/ORG/Net. Next let's see how it is called.
Copy code The code is as follows:
import("Com.Buyback.QueryAmazon");
import("ORG.Net.Http");
class Image {
public static function getImage($isbn) {
$bookInformModel = D("bookinform");
$result = $bookInformModel->where("isbn='$isbn'")->select();
if($result[0]['image'] == ""){
$data ['inform_id'] = $result[0]['inform_id'];
$remoteUrl = QueryAmazon::getImage($isbn);
if(!empty($remoteUrl['ImageURL'])){
$localUrl = "Public/bookcover/".$isbn.".jpg";
Http::curl_download($remoteUrl['ImageURL'], "./".$localUrl);
} else{
$localUrl = "Public/bookcover/unknownbook.png";
}
$data['image'] = $localUrl;
$bookInformModel->save($data);
return $localUrl;
}
return $result[0]['image'];
}
}
?>
here I first determine whether there is the image information in the database. If not, I call Amazon's webservice to obtain the image address remotely, and then use
to copy the code The code is as follows:
Http::curl_download($remoteUrl['ImageURL'], "./".$localUrl);
The first parameter of the curl_download method is the remote image address , the second parameter is the address saved to the local area.
OK, it’s that simple~~
http://www.bkjia.com/PHPjc/324070.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324070.htmlTechArticleHttp class is under the directory ThinkPHP/Lib/ORG/Net. Next let's see how it is called. Copy the code The code is as follows: ?php import("Com.Buyback.QueryAmazon"); import("ORG.Net.Http"); class Im...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn