Michael.K
好像跟Google Cloud的關係沒太大重疊...
What?
只好參考別人的作法
<?php
function create_curl($url, $filename, $method)
{
$fn = fopen($filename, 'r');
$ch = curl_init($url);
curl_setopt($ch, $method, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if ($method == CURLOPT_POST) {
curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents($filename));
} else {
curl_setopt($ch, CURLOPT_INFILE, $fn);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($filename));
}
$response = curl_exec($ch);
fclose($fn);
return json_decode($response, true);
}
<?php
function upload_to_pastec($filename)
{
$index = md5($filename);
return create_curl(
"http://localhost:4212/index/images/{$index}",
$filename,
CURLOPT_PUT
);
}
function get_image($filename)
{
resize(450, "{$filename}.bak", $filename);
$response = create_curl(
"http://localhost:4212/index/searcher",
"{$filename}.bak.jpg",
CURLOPT_POST
);
return $response["image_ids"];
}
According to that data, in case of websites well-optimized for graphics, the number of visits resulting from image search may vary from 20 to even 60% of all visits from Google.
代表你網站的流量一半都是由圖片搜尋貢獻
問與答