私はライブラリプロジェクトを使用しています:google-api-php-client-0.6.1.tar.gts。例をコピーしますhttps://developers.google.com/drive/v2/reference/about/get?hl=ru:
function printAbout($service) {
try {
$about = $service->about->get();
print "Current user name: " . $about->getName();
print "Root folder ID: " . $about->getRootFolderId();
print "Total quota (bytes): " . $about->getQuotaBytesTotal();
print "Used quota (bytes): " . $about->getQuotaBytesUsed();
} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
}
}
PHPエラー:致命的なエラー:非オブジェクトでのメンバー関数getName()の呼び出し......
$ aboutがオブジェクトに割り当てられておらず、次のタイプの配列:
Array (
[kind] => drive#file
[id] => 0B6xE_F1PfpXTWUVUNE5nZW5qYUU
[etag] => "Ys3khhcpAWaV7oeqaRGUOvsvqpo/MTM2MjEyNTY4MjE5NA"
[selfLink] => https://www.googleapis.com/drive/v2/files/0B6xE_F1PfpXTWUVUNE5nZW5qYUU
[webContentLink] => https://docs.google.com/uc?id=0B6xE_F1PfpXTWUVUNE5nZW5qYUU&export=download
[alternateLink] => https://docs.google.com/file/d/0B6xE_F1PfpXTWUVUNE5nZW5qYUU/edit
[iconLink] => https://ssl.gstatic.com/docs/doclist/images/icon_10_word_list.png
[thumbnailLink] => https://lh5.googleusercontent.com/Mb3p9nFVuzwGaaKVVxfyBKwPOS4-0QjiSUi7EcfiA6_QBgRThM7NrPOcBC-UcRKt6Q=s220
[title] => Kniga3_A5.doc
[mimeType] => application/msword
[labels] => Array
(
[starred] =>
[hidden] =>
[trashed] =>
[restricted] =>
[viewed] =>
)
[createdDate] => 2013-03-01T08:14:40.352Z
[modifiedDate] => 2013-03-01T08:14:42.194Z
[modifiedByMeDate] => 2013-03-01T08:14:40.332Z
[parents] => Array ..................
配列の例は関数printFileで取得されますが、形式はprintAboutと同じです。
私はそれがオブジェクトを与えられるべきだと思います....
私が他の関数で気づいたのと同じ間違い。