/
CreateAction.php
39 lines (27 loc) · 947 Bytes
/
CreateAction.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
namespace App\Action;
class CreateAction extends Base
{
public function run()
{
try {
$fb = $this->getFacebookClient();
$params = array();
$params['installed'] = $this->getInspekt()->post->getInt('installed');
$params['permissions'] = $this->getInspekt()->post->getRaw('permissions');
$user = $fb->api('/'.$fb->getAppId().'/accounts/test-users', 'POST', $params);
if (is_array($user)){
$fb->setAccessToken($user['access_token']);
$details = $fb->api('/me');
$user = \array_merge($user,$details);
$success = true;
}
} catch (\Exception $e) {
$this->redirectToError($e);
return;
}
$tpl = $this->getTplEngine()->loadTemplate('create.html');
$tpl->display(array('error' => !isset($success), 'user' => $user));
}
}
?>