임 "서비스 계정"과 캘린더 응용 프로그램을 만들려고하고 나는 구글-API-PHP 클라이언트Google 캘린더 API - 서비스 계정 오류
을의 최신 버전을 다운로드 그리고 내가 serviceAccount.php에 액세스 할 때 내가 얻을 다음과 같은 오류 :
치명적인 오류 : 정의되지 않은 방법 apiClient에 전화 :: /home/fmentert/public_html/reservations/google-api-php-client/examples/calendar/serviceAccount.php에서 setAssertionCredentials을() 라인에서 44
이것은 내 serviceAccount.php 파일입니다. 내 고객 ID, 서비스 계정 이름 및 키 파일을 추가했습니다. 또한. 나는 내 PHP 버전은 5.2.17
가 는define('CLIENT_ID', '896988357842.apps.googleusercontent.com');
define('SERVICE_ACCOUNT_NAME', '[email protected]');
// Make sure you keep your key.p12 file in a secure location, and isn't
// readable by others.
define('KEY_FILE', 'bqwe3287e42d1c2342349f4c9769asdas55-privatekey.p12');
$client = new apiClient();
$client->setApplicationName("Google Prediction Sample");
// Set your cached access token. Remember to replace $_SESSION with a
// real database or memcached.
session_start();
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
}
// Load the key in PKCS 12 format (you need to download this from the
// Google API Console when the service account was created.
$key = file_get_contents(KEY_FILE);
$client->setAssertionCredentials(new apiAssertionCredentials( // THIS IS LINE 44
SERVICE_ACCOUNT_NAME,
array('https://www.googleapis.com/auth/prediction'),
$key)
); ....
가
이 사람이 잘못 알고 있나요()의 정의 const를 변경?
게시 한 코드가 잘못된 URL에서 토큰을 받으려고합니다. https://www.googleapis.com/auth/prediction URL은 예측 서비스를위한 것입니다. 캘린더 서비스의 경우 https://www.googleapis.com/auth/calendar가 필요합니다. 아래의 응답에서 우리는 apiClient.php 파일을 포함하고 src/contrib/apiCalendarService.php 파일에 ADD를 추가해야합니다. 코드를 읽으면 메모를 읽거나 찾고있는 코드를 붙여 넣을 수 있다고 추측합니다. 당신의 목적에 부합하는 코드의 논리에 – IberoMedia