forked from fordnox/Zend_Auth_Adapter_Facebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
69 lines (52 loc) · 1.77 KB
/
README
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
Zend_Auth_Adapter_Facebook
================
This repository contains the open source Facebook oAuth2 adapter for Zend Framework that allows you to utilize the
above on your website.
Author
-----
Author of this software is Andrius Putna <fordnox@gmail.com>
Released under Zend Framework license
Usage
-----
The [examples][examples] are a good place to start. The minimal you'll need to
have is:
..application/configs/application.ini
; ------------------------------------------
; Facebook
; ------------------------------------------
facebook.appId = "<Facebook appId>"
facebook.secret = "<Facebook secret>"
facebook.permissions = "<List of permissions to request>"
..application/controller/AuthController.php
<?php
class AuthController extends Zend_Controller_Action
{
public function indexAction()
{
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$this->_helper->redirector('index', 'profile');
}
$bootstrap = $this->getInvokeArg('bootstrap');
$array = $bootstrap->getOption('facebook');
$adapter = new Zend_Auth_Adapter_Facebook($array);
$token = $this->_getParam('code');
if($token) {
$adapter->setToken($token);
$result = $auth->authenticate($adapter);
if ($result->isValid()) {
$access_token = $auth->getIdentity();
// do your stuff with access token
} else {
print $result->getMessages();
}
} else {
$adapter->redirect();
}
}
}
Feedback
--------
We are relying on the [GitHub issues tracker][issues] linked from above for
feedback. File bugs or other issues [here][issues].
[issues]: http://github.com/fordnox/Zend_Auth_Adapter_Facebook/issues