我是 Laravel 的新手,当然这个问题有一个明显的答案,但我无法将 Laravel 5 与 Google Api 连接起来。
我像往常一样用作曲家安装了 Api,它在我的供应商文件夹中,但现在我不确定如何使用它。
我还没有找到答案(因为这一定非常简单)。
可能我错过了命名空间调用或类似的东西。
在我的 IndexController 上,我有:
<?php
namespace App\Http\Controllers;
class IndexController extends Controller {
/**
* Show the application welcome screen to the user.
*
* @return Response
*/
public function index()
{
$client = new Google_Client();
$client->setApplicationName("Client_Library_Examples");
$client->setDeveloperKey("HERE_GOES_MY_KEY");
$service = new Google_Service_Drive($client);
$results = $service->volumes->listVolumes();
foreach ($results as $item) {
echo $item['volumeInfo']['title'], "<br /> \n";
}
}
}
我得到的错误是:
找不到类“App\Http\Controllers\Google_Client”
我认为这可能是 autoload_classmap 的问题,但是定义了所有 GoogleApi 类,例如:
(...)
'Google_Client' => $vendorDir 。'/google/apiclient/src/Google/Client.php',
(...)
'Google_Service_Drive' => $vendorDir 。'/google/apiclient/src/Google/Service/Drive.php',
感谢您的耐心和帮助!