Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
user.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 User class for the Joomla Platform.
16  *
17  * @package Joomla.Platform
18  * @subpackage Facebook
19  *
20  * @see http://developers.facebook.com/docs/reference/api/user/
21  * @since 13.1
22  */
24 {
25  /**
26  * Method to get the specified user's details. Authentication is required only for some fields.
27  *
28  * @param mixed $user Either an integer containing the user ID or a string containing the username.
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 getUser($user)
35  {
36  return $this->get($user);
37  }
38 
39  /**
40  * Method to get the specified user's friends. Requires authentication.
41  *
42  * @param mixed $user Either an integer containing the user ID or a string containing the username.
43  * @param integer $limit The number of objects per page.
44  * @param integer $offset The object's number on the page.
45  *
46  * @return mixed The decoded JSON response or false if the client is not authenticated.
47  *
48  * @since 13.1
49  */
50  public function getFriends($user, $limit = 0, $offset = 0)
51  {
52  return $this->getConnection($user, 'friends', '', $limit, $offset);
53  }
54 
55  /**
56  * Method to get the user's incoming friend requests. Requires authentication and read_requests permission.
57  *
58  * @param mixed $user Either an integer containing the user ID or a string containing the username.
59  * @param integer $limit The number of objects per page.
60  * @param integer $offset The object's number on the page.
61  * @param string $until A unix timestamp or any date accepted by strtotime.
62  * @param string $since A unix timestamp or any date accepted by strtotime.
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 getFriendRequests($user, $limit = 0, $offset = 0, $until = null, $since = null)
69  {
70  return $this->getConnection($user, 'friendrequests', '', $limit, $offset, $until, $since);
71  }
72 
73  /**
74  * Method to get the user's friend lists. Requires authentication and read_friendlists permission.
75  *
76  * @param mixed $user Either an integer containing the user ID or a string containing the username.
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 getFriendLists($user, $limit = 0, $offset = 0, $until = null, $since = null)
87  {
88  return $this->getConnection($user, 'friendlists', '', $limit, $offset, $until, $since);
89  }
90 
91  /**
92  * Method to get the user's wall. Requires authentication and read_stream permission.
93  *
94  * @param mixed $user Either an integer containing the user ID or a string containing the username.
95  * @param integer $limit The number of objects per page.
96  * @param integer $offset The object's number on the page.
97  * @param string $until A unix timestamp or any date accepted by strtotime.
98  * @param string $since A unix timestamp or any date accepted by strtotime.
99  *
100  * @return mixed The decoded JSON response or false if the client is not authenticated.
101  *
102  * @since 13.1
103  */
104  public function getFeed($user, $limit = 0, $offset = 0, $until = null, $since = null)
105  {
106  return $this->getConnection($user, 'feed', '', $limit, $offset, $until, $since);
107  }
108 
109  /**
110  * Method to get the user's news feed. Requires authentication and read_stream permission.
111  *
112  * @param mixed $user Either an integer containing the user ID or a string containing the username.
113  * @param string $filter User's stream filter.
114  * @param boolean $location Retreive only posts with a location attached.
115  * @param integer $limit The number of objects per page.
116  * @param integer $offset The object's number on the page.
117  * @param string $until A unix timestamp or any date accepted by strtotime.
118  * @param string $since A unix timestamp or any date accepted by strtotime.
119  *
120  * @return mixed The decoded JSON response or false if the client is not authenticated.
121  *
122  * @since 13.1
123  */
124  public function getHome($user, $filter = null, $location = false, $limit = 0, $offset = 0, $until = null, $since = null)
125  {
126  $extra_fields = '';
127 
128  if ($filter != null)
129  {
130  $extra_fields = '?filter=' . $filter;
131  }
132 
133  if ($location == true)
134  {
135  $extra_fields .= (strpos($extra_fields, '?') === false) ? '?with=location' : '&with=location';
136  }
137 
138  return $this->getConnection($user, 'home', $extra_fields, $limit, $offset, $until, $since);
139  }
140 
141  /**
142  * Method to see if a user is a friend of the current user. Requires authentication.
143  *
144  * @param mixed $current_user Either an integer containing the user ID or a string containing the username for the current user.
145  * @param mixed $user Either an integer containing the user ID or a string containing the username for the user.
146  *
147  * @return mixed The decoded JSON response or false if the client is not authenticated.
148  *
149  * @since 13.1
150  */
151  public function hasFriend($current_user, $user)
152  {
153  return $this->getConnection($current_user, 'friends/' . $user);
154  }
155 
156  /**
157  * Method to get mutual friends of one user and the current user. Requires authentication.
158  *
159  * @param mixed $current_user Either an integer containing the user ID or a string containing the username for the current user.
160  * @param mixed $user Either an integer containing the user ID or a string containing the username for the user.
161  * @param integer $limit The number of objects per page.
162  * @param integer $offset The object's number on the page.
163  *
164  * @return mixed The decoded JSON response or false if the client is not authenticated.
165  *
166  * @since 13.1
167  */
168  public function getMutualFriends($current_user, $user, $limit = 0, $offset = 0)
169  {
170  return $this->getConnection($current_user, 'mutualfriends/' . $user, '', $limit, $offset);
171  }
172 
173  /**
174  * Method to get the user's profile picture. Requires authentication.
175  *
176  * @param mixed $user Either an integer containing the user ID or a string containing the username.
177  * @param boolean $redirect If false this will return the URL of the profile picture without a 302 redirect.
178  * @param string $type To request a different photo use square | small | normal | large.
179  *
180  * @return string The URL to the user's profile picture.
181  *
182  * @since 13.1
183  */
184  public function getPicture($user, $redirect = true, $type = null)
185  {
186  $extra_fields = '';
187 
188  if ($redirect == false)
189  {
190  $extra_fields = '?redirect=false';
191  }
192 
193  if ($type != null)
194  {
195  $extra_fields .= (strpos($extra_fields, '?') === false) ? '?type=' . $type : '&type=' . $type;
196  }
197 
198  return $this->getConnection($user, 'picture', $extra_fields);
199  }
200 
201  /**
202  * Method to get the user's family relationships. Requires authentication and user_relationships permission..
203  *
204  * @param mixed $user Either an integer containing the user ID or a string containing the username.
205  * @param integer $limit The number of objects per page.
206  * @param integer $offset The object's number on the page.
207  *
208  * @return mixed The decoded JSON response or false if the client is not authenticated.
209  *
210  * @since 13.1
211  */
212  public function getFamily($user, $limit = 0, $offset = 0)
213  {
214  return $this->getConnection($user, 'family', '', $limit, $offset);
215  }
216 
217  /**
218  * Method to get the user's notifications. Requires authentication and manage_notifications permission.
219  *
220  * @param mixed $user Either an integer containing the user ID or a string containing the username.
221  * @param boolean $read Enables you to see notifications that the user has already read.
222  * @param integer $limit The number of objects per page.
223  * @param integer $offset The object's number on the page.
224  * @param string $until A unix timestamp or any date accepted by strtotime.
225  * @param string $since A unix timestamp or any date accepted by strtotime.
226  *
227  * @return mixed The decoded JSON response or false if the client is not authenticated.
228  *
229  * @since 13.1
230  */
231  public function getNotifications($user, $read = null, $limit = 0, $offset = 0, $until = null, $since = null)
232  {
233  if ($read == true)
234  {
235  $read = '?include_read=1';
236  }
237 
238  // Send the request.
239  return $this->getConnection($user, 'notifications', $read, $limit, $offset, $until, $since);
240  }
241 
242  /**
243  * Method to mark a notification as read. Requires authentication and manage_notifications permission.
244  *
245  * @param string $notification The notification id.
246  *
247  * @return boolean Returns true if successful, and false otherwise.
248  *
249  * @since 13.1
250  */
251  public function updateNotification($notification)
252  {
253  $data['unread'] = 0;
254 
255  return $this->createConnection($notification, null, $data);
256  }
257 
258  /**
259  * Method to get the user's permissions. Requires authentication.
260  *
261  * @param mixed $user Either an integer containing the user ID or a string containing the username.
262  * @param integer $limit The number of objects per page.
263  * @param integer $offset The object's number on the page.
264  *
265  * @return mixed The decoded JSON response or false if the client is not authenticated.
266  *
267  * @since 13.1
268  */
269  public function getPermissions($user, $limit = 0, $offset = 0)
270  {
271  return $this->getConnection($user, 'permissions', '', $limit, $offset);
272  }
273 
274  /**
275  * Method to revoke a specific permission on behalf of a user. Requires authentication.
276  *
277  * @param mixed $user Either an integer containing the user ID or a string containing the username.
278  * @param string $permission The permission to revoke. If none specified, then this will de-authorize the application completely.
279  *
280  * @return mixed The decoded JSON response or false if the client is not authenticated.
281  *
282  * @since 13.1
283  */
284  public function deletePermission($user, $permission = '')
285  {
286  return $this->deleteConnection($user, 'permissions', '?permission=' . $permission);
287  }
288 
289  /**
290  * Method to get the user's albums. Requires authentication and user_photos or friends_photos permission.
291  *
292  * @param mixed $user Either an integer containing the user ID or a string containing the username.
293  * @param integer $limit The number of objects per page.
294  * @param integer $offset The object's number on the page.
295  * @param string $until A unix timestamp or any date accepted by strtotime.
296  * @param string $since A unix timestamp or any date accepted by strtotime.
297  *
298  * @return mixed The decoded JSON response or false if the client is not authenticated.
299  *
300  * @since 13.1
301  */
302  public function getAlbums($user, $limit = 0, $offset = 0, $until = null, $since = null)
303  {
304  return $this->getConnection($user, 'albums', '', $limit, $offset, $until, $since);
305  }
306 
307  /**
308  * Method to create an album for a user. Requires authentication and publish_stream permission.
309  *
310  * @param mixed $user Either an integer containing the user ID or a string containing the username.
311  * @param string $name Album name.
312  * @param string $description Album description.
313  * @param json $privacy A JSON-encoded object that defines the privacy setting for the album.
314  *
315  * @return mixed The decoded JSON response or false if the client is not authenticated.
316  *
317  * @since 13.1
318  */
319  public function createAlbum($user, $name, $description = null, $privacy = null)
320  {
321  // Set POST request parameters.
322  $data = array();
323  $data['name'] = $name;
324  $data['description'] = $description;
325  $data['privacy'] = $privacy;
326 
327  return $this->createConnection($user, 'albums', $data);
328  }
329 
330  /**
331  * Method to get the user's checkins. Requires authentication and user_checkins or friends_checkins permission
332  *
333  * @param mixed $user Either an integer containing the user ID or a string containing the username.
334  * @param integer $limit The number of objects per page.
335  * @param integer $offset The object's number on the page.
336  * @param string $until A unix timestamp or any date accepted by strtotime.
337  * @param string $since A unix timestamp or any date accepted by strtotime.
338  *
339  * @return mixed The decoded JSON response or false if the client is not authenticated.
340  *
341  * @since 13.1
342  */
343  public function getCheckins($user, $limit = 0, $offset = 0, $until = null, $since = null)
344  {
345  return $this->getConnection($user, 'checkins', '', $limit, $offset, $until, $since);
346  }
347 
348  /**
349  * Method to create a checkin for a user. Requires authentication and publish_checkins permission.
350  *
351  * @param mixed $user Either an integer containing the user ID or a string containing the username.
352  * @param string $place Id of the Place Page.
353  * @param string $coordinates A JSON-encoded string containing latitute and longitude.
354  * @param string $tags Comma separated list of USER_IDs.
355  * @param string $message A message to add to the checkin.
356  * @param string $link A link to add to the checkin.
357  * @param string $picture A picture to add to the checkin.
358  *
359  * @return mixed The decoded JSON response or false if the client is not authenticated.
360  *
361  * @since 13.1
362  */
363  public function createCheckin($user, $place, $coordinates, $tags = null, $message = null, $link = null, $picture = null)
364  {
365  // Set POST request parameters.
366  $data = array();
367  $data['place'] = $place;
368  $data['coordinates'] = $coordinates;
369  $data['tags'] = $tags;
370  $data['message'] = $message;
371  $data['link'] = $link;
372  $data['picture'] = $picture;
373 
374  return $this->createConnection($user, 'checkins', $data);
375  }
376 
377  /**
378  * Method to get the user's likes. Requires authentication and user_likes or friends_likes permission.
379  *
380  * @param mixed $user Either an integer containing the user ID or a string containing the username.
381  * @param integer $limit The number of objects per page.
382  * @param integer $offset The object's number on the page.
383  * @param string $until A unix timestamp or any date accepted by strtotime.
384  * @param string $since A unix timestamp or any date accepted by strtotime.
385  *
386  * @return mixed The decoded JSON response or false if the client is not authenticated.
387  *
388  * @since 13.1
389  */
390  public function getLikes($user, $limit = 0, $offset = 0, $until = null, $since = null)
391  {
392  return $this->getConnection($user, 'likes', '', $limit, $offset, $until, $since);
393  }
394 
395  /**
396  * Method to see if a user likes a specific Page. Requires authentication.
397  *
398  * @param mixed $user Either an integer containing the user ID or a string containing the username.
399  * @param string $page Facebook ID of the Page.
400  *
401  * @return mixed The decoded JSON response or false if the client is not authenticated.
402  *
403  * @since 13.1
404  */
405  public function likesPage($user, $page)
406  {
407  return $this->getConnection($user, 'likes/' . $page);
408  }
409 
410  /**
411  * Method to get the current user's events. Requires authentication and user_events or friends_events permission.
412  *
413  * @param mixed $user Either an integer containing the user ID or a string containing the username.
414  * @param integer $limit The number of objects per page.
415  * @param integer $offset The object's number on the page.
416  * @param string $until A unix timestamp or any date accepted by strtotime.
417  * @param string $since A unix timestamp or any date accepted by strtotime.
418  *
419  * @return mixed The decoded JSON response or false if the client is not authenticated.
420  *
421  * @since 13.1
422  */
423  public function getEvents($user, $limit = 0, $offset = 0, $until = null, $since = null)
424  {
425  return $this->getConnection($user, 'events', '', $limit, $offset, $until, $since);
426  }
427 
428  /**
429  * Method to create an event for a user. Requires authentication create_event permission.
430  *
431  * @param mixed $user Either an integer containing the user ID or a string containing the username.
432  * @param string $name Event name.
433  * @param string $start_time Event start time as UNIX timestamp.
434  * @param string $end_time Event end time as UNIX timestamp.
435  * @param string $description Event description.
436  * @param string $location Event location.
437  * @param string $location_id Facebook Place ID of the place the Event is taking place.
438  * @param string $privacy_type Event privacy setting, a string containing 'OPEN' (default), 'CLOSED', or 'SECRET'.
439  *
440  * @return mixed The decoded JSON response or false if the client is not authenticated.
441  *
442  * @since 13.1
443  */
444  public function createEvent($user, $name, $start_time, $end_time = null, $description = null,
445  $location = null, $location_id = null, $privacy_type = null)
446  {
447  // Set POST request parameters.
448  $data = array();
449  $data['start_time'] = $start_time;
450  $data['name'] = $name;
451  $data['end_time'] = $end_time;
452  $data['description'] = $description;
453  $data['location'] = $location;
454  $data['location_id'] = $location_id;
455  $data['privacy_type'] = $privacy_type;
456 
457  return $this->createConnection($user, 'events', $data);
458  }
459 
460  /**
461  * Method to edit an event. Requires authentication create_event permission.
462  *
463  * @param mixed $event Event ID.
464  * @param string $name Event name.
465  * @param string $start_time Event start time as UNIX timestamp.
466  * @param string $end_time Event end time as UNIX timestamp.
467  * @param string $description Event description.
468  * @param string $location Event location.
469  * @param string $location_id Facebook Place ID of the place the Event is taking place.
470  * @param string $privacy_type Event privacy setting, a string containing 'OPEN' (default), 'CLOSED', or 'SECRET'.
471  *
472  * @return mixed The decoded JSON response or false if the client is not authenticated.
473  *
474  * @since 13.1
475  */
476  public function editEvent($event, $name = null, $start_time = null, $end_time = null, $description = null,
477  $location = null, $location_id = null, $privacy_type = null)
478  {
479  // Set POST request parameters.
480  $data = array();
481  $data['start_time'] = $start_time;
482  $data['name'] = $name;
483  $data['end_time'] = $end_time;
484  $data['description'] = $description;
485  $data['location'] = $location;
486  $data['location_id'] = $location_id;
487  $data['privacy_type'] = $privacy_type;
488 
489  return $this->createConnection($event, null, $data);
490  }
491 
492  /**
493  * Method to delete an event. Note: you can only delete the event if it was created by the same app. Requires authentication create_event permission.
494  *
495  * @param string $event Event ID.
496  *
497  * @return boolean Returns true if successful, and false otherwise.
498  *
499  * @since 13.1
500  */
501  public function deleteEvent($event)
502  {
503  return $this->deleteConnection($event);
504  }
505 
506  /**
507  * Method to get the groups that the user belongs to. Requires authentication and user_groups or friends_groups permission.
508  *
509  * @param mixed $user Either an integer containing the user ID or a string containing the username.
510  * @param integer $limit The number of objects per page.
511  * @param integer $offset The object's number on the page.
512  *
513  * @return mixed The decoded JSON response or false if the client is not authenticated.
514  *
515  * @since 13.1
516  */
517  public function getGroups($user, $limit = 0, $offset = 0)
518  {
519  return $this->getConnection($user, 'groups', '', $limit, $offset);
520  }
521 
522  /**
523  * Method to get the user's posted links. Requires authentication and user_groups or friends_groups permission.
524  *
525  * @param mixed $user Either an integer containing the user ID or a string containing the username.
526  * @param integer $limit The number of objects per page.
527  * @param integer $offset The object's number on the page.
528  * @param string $until A unix timestamp or any date accepted by strtotime.
529  * @param string $since A unix timestamp or any date accepted by strtotime.
530  *
531  * @return mixed The decoded JSON response or false if the client is not authenticated.
532  *
533  * @since 13.1
534  */
535  public function getLinks($user, $limit = 0, $offset = 0, $until = null, $since = null)
536  {
537  return $this->getConnection($user, 'links', '', $limit, $offset, $until, $since);
538  }
539 
540  /**
541  * Method to post a link on user's feed. Requires authentication and publish_stream permission.
542  *
543  * @param mixed $user Either an integer containing the user ID or a string containing the username.
544  * @param string $link Link URL.
545  * @param strin $message Link message.
546  *
547  * @return mixed The decoded JSON response or false if the client is not authenticated.
548  *
549  * @since 13.1
550  */
551  public function createLink($user, $link, $message = null)
552  {
553  // Set POST request parameters.
554  $data = array();
555  $data['link'] = $link;
556  $data['message'] = $message;
557 
558  return $this->createConnection($user, 'feed', $data);
559  }
560 
561  /**
562  * Method to delete a link. Requires authentication and publish_stream permission.
563  *
564  * @param mixed $link The Link ID.
565  *
566  * @return boolean Returns true if successful, and false otherwise.
567  *
568  * @since 13.1
569  */
570  public function deleteLink($link)
571  {
572  return $this->deleteConnection($link);
573  }
574 
575  /**
576  * Method to get the user's notes. Requires authentication and user_groups or friends_groups permission.
577  *
578  * @param mixed $user Either an integer containing the user ID or a string containing the username.
579  * @param integer $limit The number of objects per page.
580  * @param integer $offset The object's number on the page.
581  * @param string $until A unix timestamp or any date accepted by strtotime.
582  * @param string $since A unix timestamp or any date accepted by strtotime.
583  *
584  * @return mixed The decoded JSON response or false if the client is not authenticated.
585  *
586  * @since 13.1
587  */
588  public function getNotes($user, $limit = 0, $offset = 0, $until = null, $since = null)
589  {
590  return $this->getConnection($user, 'notes', '', $limit, $offset, $until, $since);
591  }
592 
593  /**
594  * Method to create a note on the behalf of the user.
595  * Requires authentication and publish_stream permission, user_groups or friends_groups permission.
596  *
597  * @param mixed $user Either an integer containing the user ID or a string containing the username.
598  * @param string $subject The subject of the note.
599  * @param string $message Note content.
600  *
601  * @return mixed The decoded JSON response or false if the client is not authenticated.
602  *
603  * @since 13.1
604  */
605  public function createNote($user, $subject, $message)
606  {
607  // Set POST request parameters.
608  $data = array();
609  $data['subject'] = $subject;
610  $data['message'] = $message;
611 
612  return $this->createConnection($user, 'notes', $data);
613  }
614 
615  /**
616  * Method to get the user's photos. Requires authentication and user_groups or friends_groups permission.
617  *
618  * @param mixed $user Either an integer containing the user ID or a string containing the username.
619  * @param integer $limit The number of objects per page.
620  * @param integer $offset The object's number on the page.
621  * @param string $until A unix timestamp or any date accepted by strtotime.
622  * @param string $since A unix timestamp or any date accepted by strtotime.
623  *
624  * @return mixed The decoded JSON response or false if the client is not authenticated.
625  *
626  * @since 13.1
627  */
628  public function getPhotos($user, $limit = 0, $offset = 0, $until = null, $since = null)
629  {
630  return $this->getConnection($user, 'photos', '', $limit, $offset, $until, $since);
631  }
632 
633  /**
634  * Method to post a photo on user's wall. Requires authentication and publish_stream permission, user_groups or friends_groups permission.
635  *
636  * @param mixed $user Either an integer containing the user ID or a string containing the username.
637  * @param string $source Path to photo.
638  * @param string $message Photo description.
639  * @param string $place Facebook ID of the place associated with the photo.
640  * @param boolean $no_story If set to 1, optionally suppresses the feed story that is automatically
641  * generated on a user’s profile when they upload a photo using your application.
642  *
643  * @return mixed The decoded JSON response or false if the client is not authenticated.
644  *
645  * @since 13.1
646  */
647  public function createPhoto($user, $source, $message = null, $place = null, $no_story = null)
648  {
649  // Set POST request parameters.
650  $data = array();
651  $data[basename($source)] = '@' . realpath($source);
652  $data['message'] = $message;
653  $data['place'] = $place;
654  $data['no_story'] = $no_story;
655 
656  return $this->createConnection($user, 'photos', $data, array('Content-Type' => 'multipart/form-data'));
657  }
658 
659  /**
660  * Method to get the user's posts. Requires authentication and read_stream permission for non-public posts.
661  *
662  * @param mixed $user Either an integer containing the user ID or a string containing the username.
663  * @param boolean $location Retreive only posts with a location attached.
664  * @param integer $limit The number of objects per page.
665  * @param integer $offset The object's number on the page.
666  * @param string $until A unix timestamp or any date accepted by strtotime.
667  * @param string $since A unix timestamp or any date accepted by strtotime.
668  *
669  * @return mixed The decoded JSON response or false if the client is not authenticated.
670  *
671  * @since 13.1
672  */
673  public function getPosts($user, $location = false, $limit = 0, $offset = 0, $until = null, $since = null)
674  {
675  if ($location == true)
676  {
677  $location = '?with=location';
678  }
679 
680  // Send the request.
681  return $this->getConnection($user, 'posts', $location, $limit, $offset, $until, $since);
682  }
683 
684  /**
685  * Method to post on a user's wall. Message or link parameter is required. Requires authentication and publish_stream permission.
686  *
687  * @param mixed $user Either an integer containing the user ID or a string containing the username.
688  * @param string $message Post message.
689  * @param string $link Post URL.
690  * @param string $picture Post thumbnail image (can only be used if link is specified)
691  * @param string $name Post name (can only be used if link is specified).
692  * @param string $caption Post caption (can only be used if link is specified).
693  * @param string $description Post description (can only be used if link is specified).
694  * @param array $actions Post actions array of objects containing name and link.
695  * @param string $place Facebook Page ID of the location associated with this Post.
696  * @param string $tags Comma-separated list of Facebook IDs of people tagged in this Post.
697  * For example: 1207059,701732. You cannot specify this field without also specifying a place.
698  * @param string $privacy Post privacy settings (can only be specified if the Timeline being posted
699  * on belongs to the User creating the Post).
700  * @param string $object_attachment Facebook ID for an existing picture in the User's photo albums to use as the thumbnail image.
701  * The User must be the owner of the photo, and the photo cannot be part of a message attachment.
702  *
703  * @return mixed The decoded JSON response or false if the client is not authenticated.
704  *
705  * @since 13.1
706  */
707  public function createPost($user, $message = null, $link = null, $picture = null, $name = null, $caption = null,
708  $description = null, $actions = null, $place = null, $tags = null, $privacy = null, $object_attachment = null)
709  {
710  // Set POST request parameters.
711  $data = array();
712  $data['message'] = $message;
713  $data['link'] = $link;
714  $data['name'] = $name;
715  $data['caption'] = $caption;
716  $data['description'] = $description;
717  $data['actions'] = $actions;
718  $data['place'] = $place;
719  $data['tags'] = $tags;
720  $data['privacy'] = $privacy;
721  $data['object_attachment'] = $object_attachment;
722  $data['picture'] = $picture;
723 
724  return $this->createConnection($user, 'feed', $data);
725  }
726 
727  /**
728  * Method to delete a post. Note: you can only delete the post if it was created by the current user. Requires authentication
729  *
730  * @param string $post The Post ID.
731  *
732  * @return mixed The decoded JSON response or false if the client is not authenticated.
733  *
734  * @since 13.1
735  */
736  public function deletePost($post)
737  {
738  return $this->deleteConnection($post);
739  }
740 
741  /**
742  * Method to get the user's statuses. Requires authentication read_stream permission.
743  *
744  * @param mixed $user Either an integer containing the user ID or a string containing the username.
745  * @param integer $limit The number of objects per page.
746  * @param integer $offset The object's number on the page.
747  * @param string $until A unix timestamp or any date accepted by strtotime.
748  * @param string $since A unix timestamp or any date accepted by strtotime.
749  *
750  * @return mixed The decoded JSON response or false if the client is not authenticated.
751  *
752  * @since 13.1
753  */
754  public function getStatuses($user, $limit = 0, $offset = 0, $until = null, $since = null)
755  {
756  return $this->getConnection($user, 'statuses', '', $limit, $offset, $until, $since);
757  }
758 
759  /**
760  * Method to post a status message on behalf of the user. Requires authentication publish_stream permission.
761  *
762  * @param mixed $user Either an integer containing the user ID or a string containing the username.
763  * @param string $message Status message content.
764  *
765  * @return mixed The decoded JSON response or false if the client is not authenticated.
766  *
767  * @since 13.1
768  */
769  public function createStatus($user, $message)
770  {
771  // Set POST request parameters.
772  $data = array();
773  $data['message'] = $message;
774 
775  return $this->createConnection($user, 'feed', $data);
776  }
777 
778  /**
779  * Method to delete a status. Note: you can only delete the post if it was created by the current user.
780  * Requires authentication publish_stream permission.
781  *
782  * @param string $status The Status ID.
783  *
784  * @return mixed The decoded JSON response or false if the client is not authenticated.
785  *
786  * @since 13.1
787  */
788  public function deleteStatus($status)
789  {
790  return $this->deleteConnection($status);
791  }
792 
793  /**
794  * Method to get the videos the user has been tagged in. Requires authentication and user_videos or friends_videos permission.
795  *
796  * @param mixed $user Either an integer containing the user ID or a string containing the username.
797  * @param integer $limit The number of objects per page.
798  * @param integer $offset The object's number on the page.
799  * @param string $until A unix timestamp or any date accepted by strtotime.
800  * @param string $since A unix timestamp or any date accepted by strtotime.
801  *
802  * @return mixed The decoded JSON response or false if the client is not authenticated.
803  *
804  * @since 13.1
805  */
806  public function getVideos($user, $limit = 0, $offset = 0, $until = null, $since = null)
807  {
808  return $this->getConnection($user, 'videos', '', $limit, $offset, $until, $since);
809  }
810 
811  /**
812  * Method to post a video on behalf of the user. Requires authentication and publish_stream permission.
813  *
814  * @param mixed $user Either an integer containing the user ID or a string containing the username.
815  * @param string $source Path to video.
816  * @param string $title Video title.
817  * @param string $description Video description.
818  *
819  * @return mixed The decoded JSON response or false if the client is not authenticated.
820  *
821  * @since 13.1
822  */
823  public function createVideo($user, $source, $title = null, $description = null)
824  {
825  // Set POST request parameters.
826  $data = array();
827  $data[basename($source)] = '@' . realpath($source);
828  $data['title'] = $title;
829  $data['description'] = $description;
830 
831  return $this->createConnection($user, 'videos', $data, array('Content-Type' => 'multipart/form-data'));
832  }
833 
834  /**
835  * Method to get the posts the user has been tagged in. Requires authentication and user_videos or friends_videos permission.
836  *
837  * @param mixed $user Either an integer containing the user ID or a string containing the username.
838  * @param integer $limit The number of objects per page.
839  * @param integer $offset The object's number on the page.
840  * @param string $until A unix timestamp or any date accepted by strtotime.
841  * @param string $since A unix timestamp or any date accepted by strtotime.
842  *
843  * @return mixed The decoded JSON response or false if the client is not authenticated.
844  *
845  * @since 13.1
846  */
847  public function getTagged($user, $limit = 0, $offset = 0, $until = null, $since = null)
848  {
849  return $this->getConnection($user, 'tagged', '', $limit, $offset, $until, $since);
850  }
851 
852  /**
853  * Method to get the activities listed on the user's profile. Requires authentication and user_activities or friends_activities permission.
854  *
855  * @param mixed $user Either an integer containing the user ID or a string containing the username.
856  * @param integer $limit The number of objects per page.
857  * @param integer $offset The object's number on the page.
858  * @param string $until A unix timestamp or any date accepted by strtotime.
859  * @param string $since A unix timestamp or any date accepted by strtotime.
860  *
861  * @return mixed The decoded JSON response or false if the client is not authenticated.
862  *
863  * @since 13.1
864  */
865  public function getActivities($user, $limit = 0, $offset = 0, $until = null, $since = null)
866  {
867  return $this->getConnection($user, 'activities', '', $limit, $offset, $until, $since);
868  }
869 
870  /**
871  * Method to get the books listed on the user's profile. Requires authentication and user_likes or friends_likes permission.
872  *
873  * @param mixed $user Either an integer containing the user ID or a string containing the username.
874  * @param integer $limit The number of objects per page.
875  * @param integer $offset The object's number on the page.
876  * @param string $until A unix timestamp or any date accepted by strtotime.
877  * @param string $since A unix timestamp or any date accepted by strtotime.
878  *
879  * @return mixed The decoded JSON response or false if the client is not authenticated.
880  *
881  * @since 13.1
882  */
883  public function getBooks($user, $limit = 0, $offset = 0, $until = null, $since = null)
884  {
885  return $this->getConnection($user, 'books', '', $limit, $offset, $until, $since);
886  }
887 
888  /**
889  * Method to get the interests listed on the user's profile. Requires authentication.
890  *
891  * @param mixed $user Either an integer containing the user ID or a string containing the username.
892  * @param integer $limit The number of objects per page.
893  * @param integer $offset The object's number on the page.
894  * @param string $until A unix timestamp or any date accepted by strtotime.
895  * @param string $since A unix timestamp or any date accepted by strtotime.
896  *
897  * @return mixed The decoded JSON response or false if the client is not authenticated.
898  *
899  * @since 13.1
900  */
901  public function getInterests($user, $limit = 0, $offset = 0, $until = null, $since = null)
902  {
903  return $this->getConnection($user, 'interests', '', $limit, $offset, $until, $since);
904  }
905 
906  /**
907  * Method to get the movies listed on the user's profile. Requires authentication and user_likes or friends_likes permission.
908  *
909  * @param mixed $user Either an integer containing the user ID or a string containing the username.
910  * @param integer $limit The number of objects per page.
911  * @param integer $offset The object's number on the page.
912  * @param string $until A unix timestamp or any date accepted by strtotime.
913  * @param string $since A unix timestamp or any date accepted by strtotime.
914  *
915  * @return mixed The decoded JSON response or false if the client is not authenticated.
916  *
917  * @since 13.1
918  */
919  public function getMovies($user, $limit = 0, $offset = 0, $until = null, $since = null)
920  {
921  return $this->getConnection($user, 'movies', '', $limit, $offset, $until, $since);
922  }
923 
924  /**
925  * Method to get the television listed on the user's profile. Requires authentication and user_likes or friends_likes permission.
926  *
927  * @param mixed $user Either an integer containing the user ID or a string containing the username.
928  * @param integer $limit The number of objects per page.
929  * @param integer $offset The object's number on the page.
930  * @param string $until A unix timestamp or any date accepted by strtotime.
931  * @param string $since A unix timestamp or any date accepted by strtotime.
932  *
933  * @return mixed The decoded JSON response or false if the client is not authenticated.
934  *
935  * @since 13.1
936  */
937  public function getTelevision($user, $limit = 0, $offset = 0, $until = null, $since = null)
938  {
939  return $this->getConnection($user, 'television', '', $limit, $offset, $until, $since);
940  }
941 
942  /**
943  * Method to get the music listed on the user's profile. Requires authentication user_likes or friends_likes permission.
944  *
945  * @param mixed $user Either an integer containing the user ID or a string containing the username.
946  * @param integer $limit The number of objects per page.
947  * @param integer $offset The object's number on the page.
948  * @param string $until A unix timestamp or any date accepted by strtotime.
949  * @param string $since A unix timestamp or any date accepted by strtotime.
950  *
951  * @return mixed The decoded JSON response or false if the client is not authenticated.
952  *
953  * @since 13.1
954  */
955  public function getMusic($user, $limit = 0, $offset = 0, $until = null, $since = null)
956  {
957  return $this->getConnection($user, 'music', '', $limit, $offset, $until, $since);
958  }
959 
960  /**
961  * Method to get the user's subscribers. Requires authentication and user_subscriptions or friends_subscriptions permission.
962  *
963  * @param mixed $user Either an integer containing the user ID or a string containing the username.
964  * @param integer $limit The number of objects per page.
965  * @param integer $offset The object's number on the page.
966  *
967  * @return mixed The decoded JSON response or false if the client is not authenticated.
968  *
969  * @since 13.1
970  */
971  public function getSubscribers($user, $limit = 0, $offset = 0)
972  {
973  return $this->getConnection($user, 'subscribers', '', $limit, $offset);
974  }
975 
976  /**
977  * Method to get the people the user is subscribed to. Requires authentication and user_subscriptions or friends_subscriptions permission.
978  *
979  * @param mixed $user Either an integer containing the user ID or a string containing the username.
980  * @param integer $limit The number of objects per page.
981  * @param integer $offset The object's number on the page.
982  *
983  * @return mixed The decoded JSON response or false if the client is not authenticated.
984  *
985  * @since 13.1
986  */
987  public function getSubscribedTo($user, $limit = 0, $offset = 0)
988  {
989  return $this->getConnection($user, 'subscribedto', '', $limit, $offset);
990  }
991 }