Google Glass 용 Mirror API 앱을 개발 중이며 매우 근본적인 문제에 봉착했습니다. 타임 라인 항목에서 이미지를 저장하고 싶습니다.타임 라인 항목에서 이미지 첨부 파일을 어떻게 다운로드합니까?
require_once 'config.php';
require_once 'mirror-client.php';
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_MirrorService.php';
require_once 'util.php';
require 'facebook-php-sdk/src/facebook.php';
if($_SERVER['REQUEST_METHOD'] != "POST") {
http_send_status(400);
exit();
}
// Parse the request body
$body = http_get_request_body();
$request = json_decode($body, true);
// A notification has come in. If there's an attached photo, bounce it back
// to the user
$user_id = $request['userToken'];
$access_token = get_credentials($user_id);
$client = get_google_api_client();
$client->setAccessToken($access_token);
// A glass service for interacting with the Mirror API
$mirror_service = new Google_MirrorService($client);
//Save image to file
$itemId = $request['itemId'];
$timeLineItem = $mirror_service->timeline->get($itemId);
$request = new Google_HttpRequest($timeLineItem['attachments'][0]['contentUrl'], 'GET', null, null);
$httpRequest = Google_Client::$io->authenticatedRequest($request);
if ($httpRequest->getResponseHttpCode() == 200) {
$image = $httpRequest->getResponseBody();
imagejpeg($image, 'test.jpg');
} else {
// An error occurred.
die('This sucks! '. $httpRequest->getResponseBody());
}
나는이 오류가 계속 : PHP 경고 : imagejpeg()는 매개 변수 (1) 자원에게 내가 그렇게 내가 심지어 궤도에 아니라고 두려워 PHP로 새로운 오전
있을 것으로 기대 . 내가 도대체 뭘 잘못하고있는 겁니까? imagejpeg
의 첫 번째 매개 변수는 'imagecreatetruecolor()'http://www.php.net/manual/en/function.imagecreatetruecolor.php
로 만든 자원이어야한다
대단히 고마워요! – theJosh