0
|
1 <?php
|
|
2
|
|
3 /**
|
|
4 * New Page APIs
|
|
5 *
|
|
6 * @author Xavier Barbosa
|
|
7 * @since 13 February, 2013
|
|
8 * @link https://developers.facebook.com/blog/post/2012/03/14/new-page-apis/
|
|
9 **/
|
|
10
|
|
11 use Mute\Facebook\App;
|
|
12
|
|
13 /**
|
|
14 * Default params
|
|
15 **/
|
|
16
|
|
17 $app_id = "YOUR_APP_ID";
|
|
18 $app_secret = "YOUR_APP_SECRET";
|
|
19
|
|
20 /**
|
|
21 * Reading Milestones
|
|
22 **/
|
|
23
|
|
24 $app = new App($app_id, $app_secret);
|
|
25 $result = $app->get('PAGE_ID/milestones');
|
|
26
|
|
27 var_dump($result);
|
|
28
|
|
29 /**
|
|
30 * Creating a Milestone
|
|
31 **/
|
|
32
|
|
33 $result = $app->post('PAGE_ID/milestones', array(
|
|
34 'title' => 'Example Title',
|
|
35 'description' = >'Description',
|
|
36 'start_time' => 1329417443,
|
|
37 ));
|
|
38
|
|
39 var_dump($result);
|
|
40
|
|
41 /**
|
|
42 * Deleting a Milestone
|
|
43 **/
|
|
44
|
|
45 $result = $app->delete('PAGE_ID/milestones');
|
|
46
|
|
47 var_dump($result);
|
|
48
|
|
49 /**
|
|
50 * Editing a Page's Attributes
|
|
51 **/
|
|
52
|
|
53 $result = $app->post('PAGE_ID/milestones', array(
|
|
54 'about' => 'About Text',
|
|
55 'phone' => '415-448-4444',
|
|
56 'description' => 'Description',
|
|
57 'general_info' => 'Info',
|
|
58 'website' => 'http://example.com',
|
|
59 ));
|
|
60
|
|
61 var_dump($result);
|
|
62
|
|
63 /**
|
|
64 * Setting Page's cover photo
|
|
65 **/
|
|
66
|
|
67 $result = $app->post('PAGE_ID/milestones', array(
|
|
68 'cover' => 1232343,
|
|
69 'offset_y' => 30,
|
|
70 'no_feed_story' => false,
|
|
71 ));
|
|
72
|
|
73 var_dump($result);
|
|
74
|
|
75 /**
|
|
76 * Reading Page's cover photo
|
|
77 **/
|
|
78
|
|
79 $result = $app->fql('SELECT pic_cover from page where page_id = PAGE_ID');
|
|
80
|
|
81 var_dump($result);
|
|
82
|
|
83 /**
|
|
84 * Reading Page Apps
|
|
85 **/
|
|
86
|
|
87 $result = $app->fql('SELECT name, link FROM profile_view WHERE profile_id = PAGE_ID');
|
|
88
|
|
89 var_dump($result);
|
|
90
|
|
91 /**
|
|
92 * Updating a Page App's Image
|
|
93 **/
|
|
94
|
|
95 $result = $app->post('PAGE_ID/tabs/app_<APP_ID>', array(
|
|
96 'custom_image_url' => 'http://example.com/image.jpg',
|
|
97 ));
|
|
98
|
|
99 var_dump($result);
|
|
100
|
|
101 /**
|
|
102 * Uploading a Page App's Image
|
|
103 **/
|
|
104
|
|
105 $result = $app->post('PAGE_ID/tabs/app_<APP_ID>', null, array(
|
|
106 'custom_image' => realpath('tab_image.png'),
|
|
107 ));
|
|
108
|
|
109 var_dump($result);
|
|
110
|
|
111 /**
|
|
112 * Reading Messages
|
|
113 **/
|
|
114
|
|
115 $result = $app->get('PAGE_ID/PAGE_ID/conversations');
|
|
116
|
|
117 var_dump($result);
|
|
118
|
|
119 /**
|
|
120 * Replying To a Message
|
|
121 **/
|
|
122
|
|
123 $result = $app->post('THREAD_ID/messages', array(
|
|
124 'message' => 'A Reply',
|
|
125 ));
|
|
126
|
|
127 var_dump($result);
|
|
128
|
|
129 /**
|
|
130 * Hidding a Page post
|
|
131 **/
|
|
132
|
|
133 $result = $app->post('<POST_ID>', array(
|
|
134 'is_hidden' => true,
|
|
135 ));
|
|
136
|
|
137 var_dump($result);
|
|
138
|