Witam, próbuję zdziałać coś z biblioteką google.

  1. <?php
  2. require_once 'system/config.php';
  3. require_once 'system/oauth2_google/Google_Client.php';
  4. require_once 'system/oauth2_google/contrib/Google_PlusService.php';
  5.  
  6. $client = new Google_Client();
  7. $client->setApplicationName("Google+ PHP Starter Application");
  8. $plus = new Google_PlusService($client);
  9.  
  10. if (isset($_GET['logout'])) {
  11. unset($_SESSION['token']);
  12. }
  13.  
  14. if (isset($_GET['code'])) {
  15. if (strval($_SESSION['state']) !== strval($_GET['state'])) {
  16. die("The session state did not match.");
  17. }
  18. $client->authenticate();
  19. $_SESSION['token'] = $client->getAccessToken();
  20. $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
  21. header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
  22. }
  23.  
  24. if (isset($_SESSION['token'])) {
  25. $client->setAccessToken($_SESSION['token']);
  26. }
  27.  
  28. if ($client->getAccessToken()) {
  29. $me = $plus->people->get('me');
  30. print "Your Profile: <pre>" . print_r($me, true) . "</pre>";
  31.  
  32. $params = array('maxResults' => 100);
  33. $activities = $plus->activities->listActivities('me', 'public', $params);
  34. print "Your Activities: <pre>" . print_r($activities, true) . "</pre>";
  35.  
  36. $params = array(
  37. 'orderBy' => 'best',
  38. 'maxResults' => '20',
  39. );
  40. $results = $plus->activities->search('Google+ API', $params);
  41. foreach($results['items'] as $result) {
  42. print "Search Result: <pre>{$result['object']['content']}</pre>\n";
  43. }
  44.  
  45. // The access token may have been updated lazily.
  46. $_SESSION['token'] = $client->getAccessToken();
  47. } else {
  48. $state = mt_rand();
  49. $client->setState($state);
  50. $_SESSION['state'] = $state;
  51.  
  52. $authUrl = $client->createAuthUrl();
  53. print "<a class='login' href='$authUrl'>Connect Me!</a>";
  54. }



wyskakuje mi taki błąd:


Fatal error: Uncaught exception 'Google_ServiceException' with message 'Error calling GET https://www.googleapis.com/plus/v1/people/me: (403) Insufficient Permission' in /MOJ_HOSTING/system/oauth2_google/io/Google_REST.php:66 Stack trace: #0 /MOJ_HOSTING/system/oauth2_google/io/Google_REST.php(36): Google_REST::decodeHttpResponse(Object(Google_HttpRequest)) #1 /MOJ_HOSTING/system/oauth2_google/service/Google_ServiceResource.php(186): Google_REST::execute(Object(Google_HttpRequest)) #2 /MOJ_HOSTING/system/oauth2_google/contrib/Google_PlusService.php(229): Google_ServiceResource->__call('get', Array) #3 /MOJ_HOSTING/google.php(29): Google_PeopleServiceResource->get('me') #4 {main} thrown in /MOJ_HOSTING/system/oauth2_google/io/Google_REST.php on line 66