-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsta_link.php
39 lines (27 loc) · 1.24 KB
/
insta_link.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
// Insta / FB OAuth callback
require('KEYSinstagram.php') ;
require('vendor/autoload.php') ;
require_once('api/apiconfig.php') ;
require_once('api/apifunctions.php') ;
use Instagram\AccessToken\AccessToken;
$config = array( // instantiation config params
'app_id' => IG_APPID, // facebook app id
'app_secret' => IG_APPSECRET, // facebook app secret
);
// we also need to specify the redirect uri in order to exchange our code for a token
// this points to our instalink.php script
$redirectUri = IG_REDIRECT;
// instantiate our access token class
$accessToken = new AccessToken($config);
// exchange our code for an access token
$newToken = $accessToken->getAccessTokenFromCode($_GET['code'], $redirectUri);
if (!$accessToken->isLongLived()) { // check if our access token is short lived (expires in hours)
// exchange the short lived token for a long lived token which last about 60 days
$newToken = $accessToken->getLongLivedAccessToken($newToken['access_token']);
}
$blufDB = init_database('live') ;
$store = $blufDB->stmt_init() ;
$store->prepare("REPLACE INTO systemConfig SET varname = 'igtoken', vartext = ?, enableui = 'n'") ;
$store->bind_param('s', $newToken['access_token']) ;
mail(ADMIN_EMAIL, 'ig token', print_r($newToken, true)) ;