我是 Laravel 的新手,当然这个问题有一个明显的答案,但我无法将 Laravel 5 与 Google Api 连接起来。
我像往常一样使用 Composer 安装了 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',
感谢您的耐心和帮助!
我想我有。
我只需要设置:
use Google_Client;
use Google_Service_Drive;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)