php - I need some solution with Google API Oauth -


i'm trying pull list of google contacts , display on page name , phone number. found interesting post made lorna jane , tried code. token returned, every time revisit page, asks me authenticate again. current code, no data array pulled:

$id = 'secret.apps.googleusercontent.com'; $scope = 'https://www.google.com/m8/feeds/default/full/'; $uri = 'http://example.com/callback.php';  $params = array(   'response_type'    => 'code',   'client_id'    => $id,   'redirect_uri'    => $uri,   'scope'        => $scope ); $query = 'https://accounts.google.com/o/oauth2/auth?' . http_build_query($params); header('location: ' . filter_var($query, filter_sanitize_url)); if (isset($_get['code'])) {   $code = $_get['code'];   $token = 'https://accounts.google.com/o/oauth2/token';   $params = array(       'code'        => $code,       'client_id'    => $id,       'client_secret'    => 'clientsecret',       'redirect_uri'    => $uri,       'grant_type'    => 'authorization_code'   );   $request = new httprequest($token, httprequest::meth_post);   $request->setpostfields($params);   $request->send();   $responseobj = json_decode($request->getresponsebody());   var_dump($responseobj); } 

please let me know i'm missing. prefer pecl_http implementation, on google api library.


Comments