를 사용하고 난 Google 캘린더 API에 액세스 할 방법 내가 한 무슨 1-I는 HIWO Bundle 및 FOSUser Bundle
2 통합 번들을 모두 설치하고 지금은이 사용자 인증 및 3-I 설치 한 Google API library 토큰 및 자동로드가 에 액세스하는 서비스 래퍼 클래스를 4 만든 액세스 데이터베이스에 삽입Symfony2 구글 API, 구글 클라이언트
문제 1 :은 OAuth2를가 HIWO 번들에있는 사용하여 메신저 지금 같은데 로그인하는 동안 Google API 라이브러리에서 Oauth2를 사용하게됩니다. URL에 code
매개 변수에 -I 발견 HIW의 Oauth에 의해 제공되는 토큰이 된 것과 동일하지 않습니다 : 요청을하면서, 이는 어떤 의미와이 문제에
시험을 수행해야 확실하지을 dosent 다시 리디렉션 동안 -Tried 수동으로 토큰을 설정하고 구글 클라이언트 요청으로 아래 $cal = new \Google_Calendar($this->googleClient)
하지만
$this->googleClient->authenticate('4/PmsUDPCbxWgL1X_akVYAhvnVWqpn.ErqFdB3R6wMTOl05ti8ZT3Zpgre8fgI');
return $cal->calendarList->listCalendarList();`
오류가 수신 시뮬레이션 intiat하려고합니다 :
을3210가져 오는 중 오류의 OAuth2 액세스 토큰, 메시지 : 'redirect_uri_mismatch'
그리고 내가 redirect_uri
을 확인했다 일치
내 서비스 코드는 다음과 같습니다 :
<?php
namespace Clinic\MainBundle\Services;
use Clinic\MainBundle\Entity\Patient;
use Doctrine\Common\Persistence\ObjectManager;
/*
* @author: Ahmed Samy
*/
class GoogleInterfaceService {
/*
* Entity manager
*/
protected $em;
/*
* instance of Symfphony session
*/
protected $session;
/*
* Service container
*/
protected $container;
/*
* Google client instance
*/
protected $googleClient;
public function __construct(ObjectManager $em, $container) {
$this->em = $em;
$this->container = $container;
$this->googleClient = new \Google_Client();
$this->googleClient->setClientId('xxxxxxxx.apps.googleusercontent.com');
$this->googleClient->setClientSecret('uNnaK1o-sGH_pa6Je2jfahpz');
$this->googleClient->setRedirectUri('http://hacdc.com/app_dev.php/login/check-google');
$this->googleClient->setDeveloperKey('xxxxxxxxxxxxxxxxxxxx');
$this->googleClient->setApplicationName("Google Calendar PHP Starter Application");
}
public function getCalendar() {
$cal = new \Google_Calendar($this->googleClient);
//setting token manually
$this->googleClient->authenticate('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
return $cal->calendarList->listCalendarList();
}
}
그리고 난 덤프 $this->googleClient
내가 얻을
protected 'scopes' =>
array (size=0)
empty
protected 'useObjects' => boolean false
protected 'services' =>
array (size=0)
empty
private 'authenticated' => boolean false