| 10582 |
lgm |
1 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
2 |
|
|
|
3 |
class OAuth2_Provider_Blooie extends OAuth2_Provider
|
|
|
4 |
{
|
|
|
5 |
public $scope = array('user.profile', 'user.picture');
|
|
|
6 |
|
|
|
7 |
public $method = 'POST';
|
|
|
8 |
|
|
|
9 |
public function url_authorize()
|
|
|
10 |
{
|
|
|
11 |
switch (ENVIRONMENT)
|
|
|
12 |
{
|
|
|
13 |
case PYRO_DEVELOPMENT:
|
|
|
14 |
return 'http://local.bloo.ie/oauth';
|
|
|
15 |
|
|
|
16 |
case PYRO_STAGING:
|
|
|
17 |
return 'http://blooie-staging.pagodabox.com/oauth';
|
|
|
18 |
|
|
|
19 |
case PYRO_PRODUCTIION:
|
|
|
20 |
return 'https://bloo.ie/oauth';
|
|
|
21 |
|
|
|
22 |
default:
|
|
|
23 |
exit('What the crap?!');
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
public function url_access_token()
|
|
|
29 |
{
|
|
|
30 |
switch (ENVIRONMENT)
|
|
|
31 |
{
|
|
|
32 |
case PYRO_DEVELOPMENT:
|
|
|
33 |
return 'http://local.bloo.ie/oauth/access_token';
|
|
|
34 |
|
|
|
35 |
case PYRO_STAGING:
|
|
|
36 |
return 'http://blooie-staging.pagodabox.com/oauth/access_token';
|
|
|
37 |
|
|
|
38 |
case PYRO_PRODUCTIION:
|
|
|
39 |
return 'https://bloo.ie/oauth/access_token';
|
|
|
40 |
|
|
|
41 |
default:
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
public function get_user_info(OAuth2_Token_Access $token)
|
|
|
45 |
{
|
|
|
46 |
$url = 'https://graph.facebook.com/me?'.http_build_query(array(
|
|
|
47 |
'access_token' => $token->access_token,
|
|
|
48 |
));
|
|
|
49 |
|
|
|
50 |
$user = json_decode(file_get_contents($url));
|
|
|
51 |
|
|
|
52 |
// Create a response from the request
|
|
|
53 |
return array(
|
|
|
54 |
'uid' => $user->id,
|
|
|
55 |
'nickname' => $user->username,
|
|
|
56 |
'name' => $user->name,
|
|
|
57 |
'first_name' => $user->first_name,
|
|
|
58 |
'last_name' => $user->last_name,
|
|
|
59 |
'email' => isset($user->email) ? $user->email : null,
|
|
|
60 |
'location' => isset($user->hometown->name) ? $user->hometown->name : null,
|
|
|
61 |
'description' => isset($user->bio) ? $user->bio : null,
|
|
|
62 |
'image' => 'https://graph.facebook.com/me/picture?type=normal&access_token='.$token->access_token,
|
|
|
63 |
'urls' => array(
|
|
|
64 |
'Facebook' => $user->link,
|
|
|
65 |
),
|
|
|
66 |
);
|
|
|
67 |
}
|
|
|
68 |
}
|