ホームページ  >  記事  >  バックエンド開発  >  Google フォトをローカルにダウンロードする PHP_PHP チュートリアル

Google フォトをローカルにダウンロードする PHP_PHP チュートリアル

WBOY
WBOYオリジナル
2016-07-13 17:37:52867ブラウズ

メソッドxxx.php?user=xxxの呼び出し

プログラムが配置されている現在のディレクトリに書き込み可能なフォルダーと書き込み可能なファイルがあることを確認してください

デフォルトの保存方法は

です

./ユーザー名/アルバム1説明/画像説明-1.画像サフィックス

関数オープン($host,$file){

$return = "";

$ヘッダー = ;

while($header!=200){

$fp = fsockopen($host, 80, $errno, $errstr, 30);

if (!$fp) {

echo "$errstr ($errno)
n";

} 他 {

$out = "GET $file HTTP/1.1rn";

$out .= "ホスト: $hostrn";

$out .= "P3P: CP="CAO PSA OUR"rn";

$out .= "ユーザーエージェント: Baiduspider+(+[url]http://www.baidu.com/search/spider.htm[/url])rn";

$out .= "接続: 閉じるrnrn";

fwrite($fp, $out);

while (!feof($fp)) {

$return .= fgets($fp,1024);

}

fclose($fp);

}

preg_match("/HTTP/1.1 (.*?) OK/",$return,$output);

$header = $output[1];

}

preg_match("/rnrn(.+)/is", $return, $out);

$return = $out[1];

return mb_convert_encoding($return, "GB2312", "UTF-8");;

}

関数 openimg($host,$file){

$return = "";

$ヘッダー = 302;

while($header==302){

$fp = fsockopen($host, 80, $errno, $errstr, 30);

if (!$fp) {

echo "$errstr ($errno)
n";

} 他 {

$out = "GET $file HTTP/1.1rn";

$out .= "ホスト: $hostrn";

$out .= "ユーザーエージェント: Baiduspider+(+[url]http://www.baidu.com/search/spider.htm[/url])rn";

$out .= "接続: 閉じるrnrn";

fwrite($fp, $out);

while (!feof($fp)) {

$return .= fgets($fp,1024);

}

fclose($fp);

}

preg_match("/HTTP/1.0 (.*?) /",$return,$output);

$header = $output[1];

}

preg_match("/rnrn(.+)/is", $return, $out);

$return = $out[1];

if($header==404) $return=;

return $return;

}

関数 img($host,$file,$dir,$name){

$data = openimg($host,$file);

// echo $dir;

$blankimg = ../images/blank.jpg;

$ファイル名 = $dir./.$name;

// echo $filename;

if(!is_dir($dir)){

if(!mkdir($dir)) die(ディレクトリ作成エラー);

}

// $data をエコー;

if (!$handle = fopen($filename, w+)) {

echo "$filename を開けません";

終了;

}

if (fwrite($handle, $data) === FALSE) {

echo "$filename を書き込めません";

終了;

}

// echo "$filename への書き込みが完了しました";

fclose($handle);

echo $filename."
rn";

}

$aid = ($_GET[aid]!=)?$_GET[aid]:0;

$user = $_GET[ユーザー];

if(!is_dir($user)){

if(!mkdir($user)) die(ディレクトリ作成エラー);

}

if($user==) die("ユーザー文字列を空白にすることはできません");

$userstr = /.$user./;

$html = str_replace("",,open(picasaweb.google.com,$userstr));

preg_match_all("/,access:publicn,title:(.*?)n,url:(.*?)n,src/s",$html,$album);

$all = count($album[1]);

if($aid>$all) die(OK);

$aurl = str_replace(x2F,/,$album[2][$aid]);

$astr = ./.$user./.$album[1][$aid];

$afile = str_replace(http://picasaweb.google.com,,$aurl);

$html = str_replace($,,open(picasaweb.google.com,$afile));

preg_match_all("/"summarytype":"text","summary":"(.*?)","contenttype":"(.*?)","contentsrc":"(.*?)","リンク":/s",$html,$pics);

$allpic = count($pics[3]);

for($i=0;$i

$pic = $pics[3][$i];

$typetemp =explode(.,$pic);

$type = $typetemp[(count($typetemp)-1)];

$pname = $pics[1][$i].-.$i...$type;

$temp =explode(ggpht.com,$pic);

$imghost = str_replace(http://,,$temp[0].ggpht.com);

$imgfile = $temp[1];

img($imghost,$imgfile,$astr,$pname);

}

$援助++;

echo ;

?>

Google フォト アルバムをダウンロード

<入力名=ユーザータイプ=テキスト>

<入力タイプ=送信>

www.bkjia.comtru​​ehttp://www.bkjia.com/PHPjc/486527.html技術記事メソッド xxx.php?user=xxx を呼び出すと、プログラムが配置されている現在のディレクトリが書き込み可能なフォルダーになります。書き込み可能なファイルのデフォルトの保存方法は ./username/album 1 description/picture suffix?php です。関数...
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。