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