Google 2

366 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
366
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Google 2

  1. 1. Go to https://code.google.com/apis/console
  2. 2. Authentication1. Get API Access$clientId = ‘YOUR_CLIENT_ID’;$clientSecret = ‘YOUR_CLIENT_SECRET’;$redirectUrl = ‘http://yourwebsite.com/’;$auth = eden(‘google)->auth($clientId , $clientSecret , $redirectUrl);
  3. 3. Authentication2. Get Login URL$scope = array( ‘SCOPE_URL_FROM_GOOGLE);$login = $auth ->getLoginUrl($scope);echo $login;
  4. 4. Authentication2. Get Login URL$scope = array( https://www.googleapis.com/auth/drive);$login = $auth ->getLoginUrl($scope);echo $login;
  5. 5. Authentication2. Get Login URL‘https://accounts.google.com/o/oauth2/auth?re sponse_type=code&client_id=1021817912223. apps.googleusercontent.com&redirect_uri=htt p%3A%2F%2Feden.eden.ph%2F&access_type= online&approval_prompt=auto&scope=https% 3A%2F%2Fwww.googleapis.com%2Fauth%2Fd rive.file+https%3A%2F%2Fwww.googleapis.co m%2Fauth%2Fdrive+https%3A%2F%2Fwww.go ogleapis.com%2Fauth%2Fplus.me’
  6. 6. Authentication2. Get Login URL
  7. 7. Authentication3. Get Token$access = $auth->getAccess($_GET[code]);print_r($access);
  8. 8. Authentication3. Get Token
  9. 9. //start sessionsession_start();//get auth$auth = eden(‘google’)->auth($clientId, $clientSecret, $redirect);//if no code and no sessionif(!isset($_GET[code]) && !isset($_SESSION*‘google_token])) { //redirect to login $login = $auth- >getLoginUrl(); header(Location: .$login); exit;}//Code is returned back from googleif(isset($_GET[code])) { //save it to session $access = $auth->getAccess($_GET[code]); $_SESSION*‘google_token] = $access[access_token];}
  10. 10. GoogleDrive
  11. 11. Google Drive//Instantiate Google Drive Class$drive = eden(google) ->drive(‘[YOUR_ACCESS_TOKEN]’);
  12. 12. Google Drive//Instantiate Google Drive Class$drive = eden(google) ->drive(‘ya29.AHES6ZSNBMKBaoge1dF6zmAkIgJd9Gp aXt6MlodxuoPSB259fi1djw’);
  13. 13. Google DriveGet user drive files$files = $drive ->files() ->getList();print_r($files);
  14. 14. Google DriveGet user drive specific files$files = $drive ->files() ->getSpecific(‘[FILE_ID]’);print_r($files);
  15. 15. Google DriveMove file to trash$files = $drive ->files() ->trash(‘[FILE_ID]’);print_r($files);
  16. 16. Google DriveDelete a file$files = $drive ->files() ->delete(‘[FILE_ID]’);print_r($files);
  17. 17. http://pastie.org/5385973

×