Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [HTML][PHP]Google Workspacec SDK API
phpamator
post 17.08.2023, 11:13:28
Post #1





Grupa: Zarejestrowani
Postów: 321
Pomógł: 3
Dołączył: 10.07.2016
Skąd: UK-raine

Ostrzeżenie: (0%)
-----


Hey Panowie i Panie,

Potrzebuję jakiegoś przykłądu i jeśłi ktoś posiada jakiś krok po kroku co trzeba zrobić, żeby to w końcu uruchomić. Od kilku dni próbuję ale ciągle napotykam jakieś problemu i nie wiem czy ja taki 'tępy" jestem czy to API jest takie popierniczone.

Co chciałbym osiągnąć, po ierwsze w końcu podłączyć się z pozytywnym efektem co jak narazie .... mnie zabija,
niby robię wszystko jak napisane i dalej mam problem.

Używam sugerowanego Google API CLient 2.0

w końcu udało mi się odczytać listę folderów ale nie mogę nic więcej, np status użytkownika
dostaję 403 niezależnie od tego jaki scope ustawię .... ;(

Podpowiedzcie albo pokażcie jakiś przykład
  1.  
  2. echo '<pre>';
  3.  
  4. ini_set('display_errors', 1);
  5. ini_set('display_startup_errors', 1);
  6.  
  7. // Set your service account credentials and API key
  8. $serviceAccountKeyPath = 'moj.json';
  9. $apiKey = 'mojapikey';
  10.  
  11. $userEmail = 'moj@email.com';
  12.  
  13. require_once 'vendor/autoload.php';
  14.  
  15. $client = new Google_Client();
  16. $client->setApplicationName('Email Management');
  17. $client->setAuthConfig($serviceAccountKeyPath);
  18.  
  19. // Add the necessary scopes for the APIs you intend to access
  20. $client->addScope('https://www.googleapis.com/auth/admin.directory.user.readonly');
  21.  
  22. $service = new Google_Service_Directory($client);
  23.  
  24. try {
  25. // Call the API to get user status
  26. $userStatus = $service->users->get($userEmail, ['projection' => 'full']);
  27.  
  28. // Get and print the user's status information
  29. echo "User Login Status: " . ($userStatus->getSuspended() ? 'Suspended' : 'Active') . "\n";
  30. // ... and other status information ...
  31.  
  32. } catch (Google_Service_Exception $exception) {
  33. echo "Error retrieving user status: " . $exception->getMessage() . "\n";
  34. }
  35.  


Pomóżcie proszę


Serio nikt z tym nie walczy ?
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 28.05.2024 - 20:36