lavori in anagrafica per contatti google
(insuccesso)
This commit is contained in:
parent
f9a28a3d0e
commit
cd5b57e909
@ -5,10 +5,74 @@ namespace App\Http\Controllers;
|
|||||||
use App\Models\anagrafica;
|
use App\Models\anagrafica;
|
||||||
use App\Models\contatto;
|
use App\Models\contatto;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Google\Client;
|
||||||
|
Use Google\Service\PeopleService;
|
||||||
|
|
||||||
class AnagraficaController extends Controller
|
class AnagraficaController extends Controller
|
||||||
{
|
{
|
||||||
//
|
// GOOGLE CONTACTS PART
|
||||||
|
|
||||||
|
private $google_client;
|
||||||
|
|
||||||
|
/* public function getToken()
|
||||||
|
{
|
||||||
|
$client = new Client();
|
||||||
|
$client->setApplicationName('gestionale.lavorain.cloud');
|
||||||
|
if(!is_null($client->getAccessToken())){}
|
||||||
|
elseif(!is_null(session('access_token'))) // is_null(Session::get('access_token', null))
|
||||||
|
{
|
||||||
|
$client->setAccessToken(session('access_token'));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$scope = array();
|
||||||
|
$scope[] = 'https://www.googleapis.com/auth/contacts';
|
||||||
|
// $client->
|
||||||
|
putenv('GOOGLE_APPLICATION_CREDENTIALS='.storage_path('app/google-calendar/service_key.json')); //this can be created with other ENV mode server side
|
||||||
|
$client->useApplicationDefaultCredentials();
|
||||||
|
$token = $client->getAccessToken();
|
||||||
|
session(['access_token' => $token]);
|
||||||
|
}
|
||||||
|
return $client;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public function getGoogleContacts()
|
||||||
|
{
|
||||||
|
$client = $this->getToken();
|
||||||
|
$service = new PeopleService($client);
|
||||||
|
$profile = $service->people_connections->listPeopleConnections('people/me', array('personFields' => 'names,emailAddresses,phoneNumbers'));
|
||||||
|
}
|
||||||
|
public function getToken()
|
||||||
|
{
|
||||||
|
$configJson =storage_path('app/google-calendar/service_key.json');
|
||||||
|
//$configJson =storage_path('app/google-calendar/people.json');
|
||||||
|
// define an application name
|
||||||
|
$applicationName = 'gestionale-di-famiglia';
|
||||||
|
|
||||||
|
// create the client
|
||||||
|
$client = new \Google_Client();
|
||||||
|
$client->setApplicationName($applicationName);
|
||||||
|
$client->setAuthConfig($configJson);
|
||||||
|
$client->setAccessType('offline'); // necessary for getting the refresh token
|
||||||
|
$client->setApprovalPrompt ('force'); // necessary for getting the refresh token
|
||||||
|
// scopes determine what google endpoints we can access. keep it simple for now.
|
||||||
|
|
||||||
|
$client->setScopes(
|
||||||
|
[
|
||||||
|
/*\Google\Service\Oauth2::USERINFO_PROFILE,
|
||||||
|
\Google\Service\Oauth2::USERINFO_EMAIL,
|
||||||
|
\Google\Service\Oauth2::OPENID,*/
|
||||||
|
\Google\Service\PeopleService::CONTACTS // allows reading of google drive metadata
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$client->setIncludeGrantedScopes(true);
|
||||||
|
|
||||||
|
return $client;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function newContact()
|
public function newContact()
|
||||||
{
|
{
|
||||||
return view('anagrafica.form');
|
return view('anagrafica.form');
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
"creativeorange/gravatar": "^1.0",
|
"creativeorange/gravatar": "^1.0",
|
||||||
"directorytree/ldaprecord": "^2.9",
|
"directorytree/ldaprecord": "^2.9",
|
||||||
"fruitcake/laravel-cors": "^2.0",
|
"fruitcake/laravel-cors": "^2.0",
|
||||||
|
"google/apiclient": "^2.15.0",
|
||||||
"guzzlehttp/guzzle": "^7.0.1",
|
"guzzlehttp/guzzle": "^7.0.1",
|
||||||
"jeroennoten/laravel-adminlte": "^3.9",
|
"jeroennoten/laravel-adminlte": "^3.9",
|
||||||
"laravel-notification-channels/telegram": "^2.0",
|
"laravel-notification-channels/telegram": "^2.0",
|
||||||
|
2
composer.lock
generated
2
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "fee26f6948b0082f65e8b7afbce9c24b",
|
"content-hash": "c58658999463fa4485159d5f4dde1d96",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "almasaeed2010/adminlte",
|
"name": "almasaeed2010/adminlte",
|
||||||
|
@ -212,3 +212,4 @@ Route::group(['middleware'=>['permission:meetingroom']], function(){
|
|||||||
$name='Flavio';
|
$name='Flavio';
|
||||||
Mail::to('flavio.barachino@lavorain.cloud')->send(new myTestEmail($name));
|
Mail::to('flavio.barachino@lavorain.cloud')->send(new myTestEmail($name));
|
||||||
});*/
|
});*/
|
||||||
|
Route::get('test/google',[AnagraficaController::class,'getGoogleContacts']);
|
Loading…
Reference in New Issue
Block a user