Auto Download Photo Masal dari Google+ dengan PHP

pertama ente perlu nginstall PHP CLI karena programnya jalan di CMD. ato install aja xampp karena semua paket php sudah terinstal semua di xampp.
trus di "environtment variable" bagian Path, ente tambahin path di mana ente nginstall PHP tadi. klo ente nginstall xampp, path PHP nya ada di C:\xampp\php
dan ini scriptnya
key=$key;
 $this->userId=$userId;
 $this->dir=$dir;
 $this->rewrite=$rewrite;
 }
 function get($url){
 $ch = curl_init($url);
 curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:33.0) Gecko/20100101 Firefox/33.0");
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
 curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
 $jembot = curl_exec($ch);
 curl_close($ch);
 return $jembot;
 }
 function jancok(){
 $tokenpage=null;
 do{
 $gay = $this->get("https://www.googleapis.com/plus/v1/people/".$this->userId."/activities/public?key=".$this->key."&pageToken=".$tokenpage);
 $jembut = json_decode($gay);
 if(!isset($jembut->items)){
 print_r($gay);
 break;
 }
 foreach($jembut->items as $jemb){
 $dir="./";
 $mbuh = explode('T', $jemb->updated);
 $mbuhh = explode('-',$mbuh[0]);
 if($this->dir){
 $jancok=$mbuhh;
 unset($jancok[2]);
 $time = implode('-', $jancok);
 is_dir($time)?null:mkdir($time, 0777);
 $dir.=$time."/";
 }
 if(isset($jemb->object->attachments[0]->fullImage)){
 $dir2 = scandir($dir);
 $ono=false;
 unset($arrGay);
 foreach($dir2 as $dir22){
 if(preg_match("/".preg_quote(trim($mbuh[0]))."/i", $dir22)){
 $ext = explode('.', $dir22);
 unset($ext[end(array_keys($ext))]);
 $ext = implode('.', $ext);
 $exp2 = explode('_', $ext);
 $arrGay[]=(int)$exp2[1];
 $ono=true;
 }
 }
 if($ono){
 sort($arrGay);
 $end = end($arrGay);
 $index = $end;
 }else $index=1;
 $filename = $dir.$mbuh[0].'_'.$index.".jpg";
 if(file_exists($filename)){
 if($this->rewrite)unlink($filename);
 else continue;
 }
 $img = $this->get($jemb->object->attachments[0]->fullImage->url);
 
 $fp = fopen($filename, 'x') or die('error');
 fwrite($fp, $img);
 fclose($fp);
 echo $jemb->object->attachments[0]->fullImage->url." -> ".$filename."\n";
 }
 }
 if(!empty($jembut->nextPageToken) && isset($jembut->nextPageToken))$tokenpage=$jembut->nextPageToken;
 else echo "jancok";
 }while(!empty($jembut->nextPageToken) && isset($jembut->nextPageToken));
 }
}

$key="AIzaSyA.."; //API Key dari Google Developer ente
$userId="113163959577431341409"; //userId profil yg mau ente ambil foto2nya
$direktori=true; //jika true maka akan membuat folder untuk mengelompokkan foto2nya berdasarkan tahun-bulan
$rewrite=false; //jika true maka file dengan nama yg sama akan ditimpa dengan yg baru
$jancok=new rieqyns13($userId, $key, $direktori, $rewrite);
$jancok->jancok();
?>
ganti key, userid dan lainnya mulai dari baris 82-85 trus save. trus run di cmd dengan command: php nama_file.php penampakan jalannya program ntar kya gini