Subversion Repositories instagram

[/] [modules/] [ig/] [connect_user.php] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ffruehstueck
<?php
2
 
3
$http = eZHTTPTool::instance();
4
 
5
$Module = $Params['Module'];
6
 
7
$IGIni = eZINI::instance( 'instagram.ini' );
8
 
9
$config = array(
10
        'client_id' => $IGIni->variable( 'instagram', 'ClientId' ),
11
        'client_secret' => $IGIni->variable( 'instagram', 'ClientSecret' ),
12
        'grant_type' => 'authorization_code',
13
        'redirect_uri' => $IGIni->variable( 'instagram', 'RedirectURI' )
14
     );
15
// Instantiate the API handler object
16
$instagram = new Instagram($config);
17
 
18
$accessToken = $instagram->getAccessToken();
19
if( $accessToken == '' )
20
{
21
        $scope = $IGIni->variable( 'instagram', 'IGscope' );
22
        $instagram->openAuthorizationUrl( $scope );    
23
        eZExecution::cleanExit();
24
}      
25
 
26
$igUser = eZIG::fetch( $instagram->getCurrentUser()->id );
27
if( !is_object( $igUser ) )
28
{
29
        $igUser = new eZIG();
30
}
31
$igUser->setAttribute('accessToken', $accessToken );
32
$igUser->setAttribute('ig_id', $instagram->getCurrentUser()->id );
33
$igUser->setAttribute('ig_username', $instagram->getCurrentUser()->username );
34
$igUser->setAttribute('ig_profile_picture', $instagram->getCurrentUser()->profile_picture );
35
$igUser->setAttribute('ig_full_name', $instagram->getCurrentUser()->full_name );
36
$igUser->store();
37
 
38
 
39
$Module->redirectTo( "/ig/connected_users" );
40
return;