<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents('home.jpg'));
curl_setopt($ch, CURLOPT_URL,"https://photoslibrary.googleapis.com/v1/uploads/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = [
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Encoding: gzip, deflate',
'Accept-Language: en-US,en;q=0.5',
'Cache-Control: no-cache',
'Authorization: Bearer ya29.ImC_B25PEYOLFWjyahpWviQ77NrJ45GL0tYdCDtEuQeyyoO6fSZsIH4Forv5G8PKv8yuZcJJbIgj7fabJxxwfCOqoW_a51cf-xpBLhG6KxWWXKOdZnlkvQdBw182k7hj4-8',
'Content-Type: application/octet-stream; charset=utf-8',
'X-Goog-Upload-File-Name: home.jpg',
'X-Goog-Upload-Protocol: raw',
'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$server_output = curl_exec ($ch);
curl_close ($ch);
print $server_output ;
?>