Haplous Framework 

Haplous Framework Git Source Tree


Root/system/vendor/phpoauthlib2/providers/facebookauthprovider.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
 
namespace system\vendor\phpoauthlib2\providers;
 
require "OAuthDataProvider.php";
 
use phpoauthlib2\ccurl;
use phpoauthlib2\OAUTH_SCOPES;
use phpoauthlib2\OAuthDataProvider;
 
class FacebookAuthProvider extends OAuthDataProvider {
 
    public function __construct($request, $conf, $scopes=[OAUTH_SCOPES::EMAIL]) {
        parent::__construct(
            "https://graph.facebook.com/me",
            "https://www.facebook.com/dialog/oauth",
            $request
        );
 
        $this->client_secret = $conf["client_secret"];
        $this->redirectURL = $conf["redirect_uri"];
        $this->clientId = $conf["client_id"];
        $tempScopes = [];
        foreach($scopes as $scope) {
            switch ($scope) {
                case OAUTH_SCOPES::EMAIL:
                    $tempScopes[] = "email";
            }
        }
        $tempScopes[] = "public_profile";
        $this->scope = implode(" ", $tempScopes);
    }
 
    public function getEmail() {
        return $this->profileData["email"];
    }
 
    public function getFirstName() {
        return $this->profileData["first_name"];
    }
 
    public function getLastName() {
        return $this->profileData["last_name"];
    }
 
    public function getId() {
        return $this->profileData["id"];
    }
 
    public function getSource() {
        return "FACEBOOK";
    }
 
    public function parseToken() {
        $token = $this->getToken();
        return explode("=", $token)[1];
    }
 
    public function getProfile() {
        $token = $this->parseToken();
        $profileUrl = $this->profile . "?fields=first_name,last_name,name,email,age_range&access_token=" . $token;
        $curl = new ccurl($profileUrl);
        $curl->createCurl();
        $ret = (string)$curl;
        $this->profileData = json_decode($ret, true);
        return $ret;
    }
 
}

Archive Download this file

Branches

Number of commits:
Page rendered in 0.12589s using 11 queries.