1 | <?php
|
---|
2 |
|
---|
3 | function wordbook_rest_client($secret, $session_key) {
|
---|
4 | return new FacebookRestClient(WORDBOOK_FB_APIKEY, $secret,
|
---|
5 | $session_key);
|
---|
6 | }
|
---|
7 |
|
---|
8 | function wordbook_fbclient_setfbml_impl($fbclient, $text) {
|
---|
9 | try {
|
---|
10 | $result = $fbclient->profile_setFBML(null, null, $text,
|
---|
11 | null, null, $text);
|
---|
12 | $error_code = null;
|
---|
13 | $error_msg = null;
|
---|
14 | } catch (Exception $e) {
|
---|
15 | $result = null;
|
---|
16 | $error_code = $e->getCode();
|
---|
17 | $error_msg = $e->getMessage();
|
---|
18 | }
|
---|
19 | return array($result, $error_code, $error_msg);
|
---|
20 | }
|
---|
21 |
|
---|
22 | function wordbook_fbclient_publishaction_impl($fbclient, $template_id,
|
---|
23 | $template_data,
|
---|
24 | $storysize = FacebookRestClient::STORY_SIZE_SHORT) {
|
---|
25 | try {
|
---|
26 | $method = 'feed.publishUserAction';
|
---|
27 | $result = $fbclient->feed_publishUserAction($template_id,
|
---|
28 | $template_data, '', '', $storysize);
|
---|
29 | } catch (Exception $e) {
|
---|
30 | $error_code = $e->getCode();
|
---|
31 | $error_msg = $e->getMessage();
|
---|
32 | }
|
---|
33 | return array($result, $error_code, $error_msg, $method);
|
---|
34 | }
|
---|
35 |
|
---|
36 | function wordbook_fbclient_getinfo($fbclient, $fields) {
|
---|
37 | try {
|
---|
38 | $uid = $fbclient->users_getLoggedInUser();
|
---|
39 | $users = $fbclient->users_getInfo(array($uid), $fields);
|
---|
40 | $error_code = null;
|
---|
41 | $error_msg = null;
|
---|
42 | } catch (Exception $e) {
|
---|
43 | $uid = null;
|
---|
44 | $users = null;
|
---|
45 | $error_code = $e->getCode();
|
---|
46 | $error_msg = $e->getMessage();
|
---|
47 | }
|
---|
48 | return array($uid, $users, $error_code, $error_msg);
|
---|
49 | }
|
---|
50 |
|
---|
51 | function wordbook_fbclient_has_app_permission($fbclient, $ext_perm) {
|
---|
52 | try {
|
---|
53 | $uid = $fbclient->users_getLoggedInUser();
|
---|
54 | $has_permission = $fbclient->call_method(
|
---|
55 | 'facebook.users.hasAppPermission', array(
|
---|
56 | 'uid' => $uid,
|
---|
57 | 'ext_perm' => $ext_perm,
|
---|
58 | ));
|
---|
59 | $error_code = null;
|
---|
60 | $error_msg = null;
|
---|
61 | } catch (Exception $e) {
|
---|
62 | $has_permission = null;
|
---|
63 | $error_code = $e->getCode();
|
---|
64 | $error_msg = $e->getMessage();
|
---|
65 | }
|
---|
66 | return array($has_permission, $error_code, $error_msg);
|
---|
67 | }
|
---|
68 |
|
---|
69 | function wordbook_fbclient_getsession($fbclient, $token) {
|
---|
70 | try {
|
---|
71 | $result = $fbclient->auth_getSession($token);
|
---|
72 | $error_code = null;
|
---|
73 | $error_msg = null;
|
---|
74 | } catch (Exception $e) {
|
---|
75 | $result = null;
|
---|
76 | $error_code = $e->getCode();
|
---|
77 | $error_msg = $e->getMessage();
|
---|
78 | }
|
---|
79 | return array($result, $error_code, $error_msg);
|
---|
80 | }
|
---|
81 |
|
---|
82 | ?>
|
---|