在 symfony 3 中添加 Google API 客户端库
Add Google APIs Client Library in symfony 3
我想在我的 symfony 3 项目中安装 "Google APIs Client Library",但我不知道如何使用它。
我使用以下命令从“https://github.com/googleapis/google-api-php-client#download-the-release”安装库:
作曲家要求 google/apiclient:"^2.0"
接下来,我尝试在 AppKernel.php 文件、"bundles" 数组中添加命名空间,但我不知道命名空间是什么,也不知道在哪里可以找到命名空间。然后我每次都收到这个错误:
Attempted to load class "Google_Client" from namespace "AppBundle\Controller".
这是我的小功能:
/**
* @Route("/api/oAuth/login", name="api_oauth_login")
*/
public function oAuthLoginAction(Request $request)
{
$client = new Google_Client();
$client->setApplicationName("My Application");
$client->setDeveloperKey("MY_SIMPLE_API_KEY");
}
谁能帮我集成这个库?
该库不使用命名空间,因此您应该在 class 名称之前使用尾部斜杠引用 class,例如:
$client = new \Google_Client();
我想在我的 symfony 3 项目中安装 "Google APIs Client Library",但我不知道如何使用它。
我使用以下命令从“https://github.com/googleapis/google-api-php-client#download-the-release”安装库:
作曲家要求 google/apiclient:"^2.0"
接下来,我尝试在 AppKernel.php 文件、"bundles" 数组中添加命名空间,但我不知道命名空间是什么,也不知道在哪里可以找到命名空间。然后我每次都收到这个错误:
Attempted to load class "Google_Client" from namespace "AppBundle\Controller".
这是我的小功能:
/**
* @Route("/api/oAuth/login", name="api_oauth_login")
*/
public function oAuthLoginAction(Request $request)
{
$client = new Google_Client();
$client->setApplicationName("My Application");
$client->setDeveloperKey("MY_SIMPLE_API_KEY");
}
谁能帮我集成这个库?
该库不使用命名空间,因此您应该在 class 名称之前使用尾部斜杠引用 class,例如:
$client = new \Google_Client();