我试图用“服务帐户”创建一个日历应用程序,我下载了最新版本的 google-api-php-client
当我访问 serviceAccount.php 时,我收到以下错误:
致命错误:在第 44 行的 /home/fmentert/public_html/reservations/google-api-php-client/examples/calendar/serviceAccount.php 中调用未定义的方法 apiClient::setAssertionCredentials()
这是我的 serviceAccount.php 文件。我添加了我的客户 ID、服务帐户名称和密钥文件。还。我将 const 更改为 define() 我的 php 版本是 5.2.17
define('CLIENT_ID', '896988357842.apps.googleusercontent.com');
define('SERVICE_ACCOUNT_NAME', '896988357842@developer.gserviceaccount.com');
// 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)
); ....
有人知道出了什么问题吗?