$clientId, 'clientSecret' => $clientSecret, 'authorizationUri' => 'https://accounts.google.com/o/oauth2/v2/auth', // Where to return the user to if they accept your request to access their account. // You must authorize this URI in the Google API Console. 'redirectUri' => $redirectURI, 'tokenCredentialUri' => 'https://www.googleapis.com/oauth2/v4/token', 'scope' => $scopes, 'expiry' => 7200 ]); $client = new Client(['proxy' => 'http://127.0.0.1:1087']); $httpHandler = new Guzzle7HttpHandler($client); // The authorization URI will, upon redirecting, return a parameter called code. $code = $request->get('code'); if ($code == null || $code == "") { $authenticationUrl = $oauth2->buildFullAuthorizationUri(['access_type' => 'offline']); // dump($authenticationUrl); // redirect($authenticationUrl); // header("Location: " . $authenticationUrl); // redirect()->to($authenticationUrl); return redirect($authenticationUrl); } else { dump("code is " . $code); // With the code returned by the OAuth flow, we can retrieve the refresh token. $oauth2->setCode($code); $authToken = $oauth2->fetchAuthToken(); $refreshToken = $authToken['access_token']; // The UserRefreshCredentials will use the refresh token to 'refresh' the credentials when // they expire. $credentials = new UserRefreshCredentials( $scopes, [ 'client_id' => $clientId, 'client_secret' => $clientSecret, 'refresh_token' => $refreshToken ] ); session(['credentials' => $credentials]); // Return the user to the home page. // dump("before redirect"); return redirect('google/photo/index'); // header("Location: index.php"); } } function iconv_gbk_to_uft8($string){ if (!$string){ return ''; } $encode = mb_detect_encoding($string,array("ASCII","GBK","GB2312",'BIG5','UTF-8')); // dump($encode); return iconv($encode, "UTF-8",$string); } function scanFilesWithoutPath($path): array { $allFiles = []; if (is_dir($path)) { $files = scandir($path); foreach ($files as $file) { if ($file == "." || $file == "..") { continue; } if (is_dir($path . DIRECTORY_SEPARATOR . $file)) { $allFiles = array_merge($allFiles, scanFilesWithoutPath($path . DIRECTORY_SEPARATOR . $file)); } if (is_file($path . DIRECTORY_SEPARATOR . $file)) { $allFiles[] = $file; } } } return $allFiles; }