The HTTP class is below the directory thinkphp/lib/org/net. Now let's see how it's called.
Copy Code code as follows:
<?php
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 if there is no this picture information in the database, do not call Amazon's WebService from the remote access to the image address, and then use
Copy Code code as follows:
Http::curl_download ($remoteUrl [' ImageURL '], "./". $localUrl);
The first parameter of the Curl_download method is the remote picture address, and the second parameter is the address that is saved to the local.
OK, it's so simple ~ ~