-1

「サービス アカウント」でカレンダー アプリケーションを作成しようとしていて、最新バージョンの 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)
); ....

誰が何が悪いのか知っていますか?

4

2 に答える 2

1

問題はlasバージョンにあります。そこで解決策を得ることができます: https://groups.google.com/forum/#!msg/google-api-php-client/vZysbW_XgiQ/-4kSFWP8UtEJ%5B1-25%5D

475 バージョンを使用して修正します。それを使用すると、例は正常に機能します。

サルート!

于 2012-08-08T10:54:53.290 に答える
0

apiClientクラスの定義を含むファイルが含まれていないようです。これには、require_onceコマンドを使用します。

たとえば、apiClientクラスが「apiClientFile.php」というファイルで定義されている場合、PHP スクリプトは次のようになります。

require_once 'apiClientFile.php';

define('CLIENT_ID', '896988357842.apps.googleusercontent.com');
...
于 2012-06-19T19:19:05.417 に答える