-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_authenticate.php
30 lines (21 loc) · 1 KB
/
test_authenticate.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
<?php
session_start();
require('test_entrecard.php');
$my_url_path = dirname("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$oa = new OAuthEntrecard(SITE_USER_ID, SITE_SECRET);
list($token, $token_secret) = $oa->getToken(array(EC_PERM_AUTHENTICATE, EC_PERM_BALANCE, EC_PERM_WITHDRAW), $my_url_path."/test_get_balance.php");
/* Need to store token and token secret somewhere. You have two options,
either put the token and token secret into the session, in which case
you can only act on the users behalf during a request in the current
session (fine for basic services).
Or you can store the token and secret in the database. THis allows
you to act on the users behalf after the session expires or in
a cron job.
*/
$_SESSION['request_token'] = $token;
$_SESSION['request_token_secret'] = $token_secret;
unset($_SESSION['access_token']);
$authentication_url = $oa->getAuthenticationURL($token, $token_secret);
// Redirect user to authentication URL
Header('Location: '.$authentication_url);
?>