Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
group.php
Aller à la documentation de ce fichier.
1 <?php
2 /**
3  * @package Joomla.Platform
4  * @subpackage Facebook
5  *
6  * @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
7  * @license GNU General Public License version 2 or later; see LICENSE
8  */
9 
10 
11 defined('JPATH_PLATFORM') or die();
12 
13 
14 /**
15  * Facebook API Group class for the Joomla Platform.
16  *
17  * @package Joomla.Platform
18  * @subpackage Facebook
19  *
20  * @see http://developers.facebook.com/docs/reference/api/group/
21  * @since 13.1
22  */
24 {
25  /**
26  * Method to read a group. Requires authentication and user_groups or friends_groups permission for non-public groups.
27  *
28  * @param string $group The group id.
29  *
30  * @return mixed The decoded JSON response or false if the client is not authenticated.
31  *
32  * @since 13.1
33  */
34  public function getGroup($group)
35  {
36  return $this->get($group);
37  }
38 
39  /**
40  * Method to get the group's wall. Requires authentication and user_groups or friends_groups permission for non-public groups.
41  *
42  * @param string $group The group id.
43  * @param integer $limit The number of objects per page.
44  * @param integer $offset The object's number on the page.
45  * @param string $until A unix timestamp or any date accepted by strtotime.
46  * @param string $since A unix timestamp or any date accepted by strtotime.
47  *
48  * @return mixed The decoded JSON response or false if the client is not authenticated.
49  *
50  * @since 13.1
51  */
52  public function getFeed($group, $limit = 0, $offset = 0, $until = null, $since = null)
53  {
54  return $this->getConnection($group, 'feed', '', $limit, $offset, $until, $since);
55  }
56 
57  /**
58  * Method to get the group's members. Requires authentication and user_groups or friends_groups permission for non-public groups.
59  *
60  * @param string $group The group id.
61  * @param integer $limit The number of objects per page.
62  * @param integer $offset The object's number on the page.
63  *
64  * @return mixed The decoded JSON response or false if the client is not authenticated.
65  *
66  * @since 13.1
67  */
68  public function getMembers($group, $limit = 0, $offset = 0)
69  {
70  return $this->getConnection($group, 'members', '', $limit, $offset);
71  }
72 
73  /**
74  * Method to get the group's docs. Requires authentication and user_groups or friends_groups permission for non-public groups.
75  *
76  * @param string $group The group id.
77  * @param integer $limit The number of objects per page.
78  * @param integer $offset The object's number on the page.
79  * @param string $until A unix timestamp or any date accepted by strtotime.
80  * @param string $since A unix timestamp or any date accepted by strtotime.
81  *
82  * @return mixed The decoded JSON response or false if the client is not authenticated.
83  *
84  * @since 13.1
85  */
86  public function getDocs($group, $limit = 0, $offset = 0, $until = null, $since = null)
87  {
88  return $this->getConnection($group, 'docs', '', $limit, $offset, $until, $since);
89  }
90 
91  /**
92  * Method to get the groups's picture. Requires authentication and user_groups or friends_groups permission.
93  *
94  * @param string $group The group id.
95  * @param string $type To request a different photo use square | small | normal | large.
96  *
97  * @return string The URL to the group's picture.
98  *
99  * @since 13.1
100  */
101  public function getPicture($group, $type = null)
102  {
103  if ($type)
104  {
105  $type = '?type=' . $type;
106  }
107 
108  return $this->getConnection($group, 'picture', $type);
109  }
110 
111  /**
112  * Method to post a link on group's wall. Requires authentication and publish_stream permission.
113  *
114  * @param string $group The group id.
115  * @param string $link Link URL.
116  * @param strin $message Link message.
117  *
118  * @return mixed The decoded JSON response or false if the client is not authenticated.
119  *
120  * @since 13.1
121  */
122  public function createLink($group, $link, $message = null)
123  {
124  // Set POST request parameters.
125  $data = array();
126  $data['link'] = $link;
127 
128  if ($message)
129  {
130  $data['message'] = $message;
131  }
132 
133  return $this->createConnection($group, 'feed', $data);
134  }
135 
136  /**
137  * Method to delete a link. Requires authentication.
138  *
139  * @param mixed $link The Link ID.
140  *
141  * @return boolean Returns true if successful, and false otherwise.
142  *
143  * @since 13.1
144  */
145  public function deleteLink($link)
146  {
147  return $this->deleteConnection($link);
148  }
149 
150  /**
151  * Method to post on group's wall. Message or link parameter is required. Requires authentication and publish_stream permission.
152  *
153  * @param string $group The group id.
154  * @param string $message Post message.
155  * @param string $link Post URL.
156  * @param string $picture Post thumbnail image (can only be used if link is specified)
157  * @param string $name Post name (can only be used if link is specified).
158  * @param string $caption Post caption (can only be used if link is specified).
159  * @param string $description Post description (can only be used if link is specified).
160  * @param array $actions Post actions array of objects containing name and link.
161  *
162  * @return mixed The decoded JSON response or false if the client is not authenticated.
163  *
164  * @since 13.1
165  */
166  public function createPost($group, $message = null, $link = null, $picture = null, $name = null, $caption = null,
167  $description = null, $actions = null)
168  {
169  // Set POST request parameters.
170  if ($message)
171  {
172  $data['message'] = $message;
173  }
174 
175  if ($link)
176  {
177  $data['link'] = $link;
178  }
179 
180  if ($name)
181  {
182  $data['name'] = $name;
183  }
184 
185  if ($caption)
186  {
187  $data['caption'] = $caption;
188  }
189 
190  if ($description)
191  {
192  $data['description'] = $description;
193  }
194 
195  if ($actions)
196  {
197  $data['actions'] = $actions;
198  }
199 
200  if ($picture)
201  {
202  $data['picture'] = $picture;
203  }
204 
205  return $this->createConnection($group, 'feed', $data);
206  }
207 
208  /**
209  * Method to delete a post. Note: you can only delete the post if it was created by the current user. Requires authentication.
210  *
211  * @param string $post The Post ID.
212  *
213  * @return boolean Returns true if successful, and false otherwise.
214  *
215  * @since 13.1
216  */
217  public function deletePost($post)
218  {
219  return $this->deleteConnection($post);
220  }
221 
222  /**
223  * Method to post a status message on behalf of the user on the group's wall. Requires authentication and publish_stream permission.
224  *
225  * @param string $group The group id.
226  * @param string $message Status message content.
227  *
228  * @return mixed The decoded JSON response or false if the client is not authenticated.
229  *
230  * @since 13.1
231  */
232  public function createStatus($group, $message)
233  {
234  // Set POST request parameters.
235  $data = array();
236  $data['message'] = $message;
237 
238  return $this->createConnection($group, 'feed', $data);
239  }
240 
241  /**
242  * Method to delete a status. Note: you can only delete the status if it was created by the current user. Requires authentication.
243  *
244  * @param string $status The Status ID.
245  *
246  * @return boolean Returns true if successful, and false otherwise.
247  *
248  * @since 13.1
249  */
250  public function deleteStatus($status)
251  {
252  return $this->deleteConnection($status);
253  }
254 }