1<?php
2/**
3 * @package     Joomla.Platform
4 * @subpackage  Facebook
5 *
6 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
7 * @license     GNU General Public License version 2 or later; see LICENSE
8 */
9
10defined('JPATH_PLATFORM') or die();
11
12/**
13 * Facebook API Post class for the Joomla Platform.
14 *
15 * @link        http://developers.facebook.com/docs/reference/api/post/
16 * @since       3.2.0
17 * @deprecated  4.0  Use the `joomla/facebook` package via Composer instead
18 */
19class JFacebookPost extends JFacebookObject
20{
21	/**
22	 * Method to get a post. Requires authentication and read_stream permission for all data.
23	 *
24	 * @param   string  $post  The post id.
25	 *
26	 * @return  mixed   The decoded JSON response or false if the client is not authenticated.
27	 *
28	 * @since   3.2.0
29	 */
30	public function getPost($post)
31	{
32		return $this->get($post);
33	}
34
35	/**
36	 * Method to delete a post if it was created by this application. Requires authentication and publish_stream permission
37	 *
38	 * @param   string  $post  The post id.
39	 *
40	 * @return  boolean Returns true if successful, and false otherwise.
41	 *
42	 * @since   3.2.0
43	 */
44	public function deletePost($post)
45	{
46		return $this->deleteConnection($post);
47	}
48
49	/**
50	 * Method to get a post's comments. Requires authentication and read_stream permission.
51	 *
52	 * @param   string   $post    The post id.
53	 * @param   integer  $limit   The number of objects per page.
54	 * @param   integer  $offset  The object's number on the page.
55	 * @param   string   $until   A unix timestamp or any date accepted by strtotime.
56	 * @param   string   $since   A unix timestamp or any date accepted by strtotime.
57	 *
58	 * @return  mixed   The decoded JSON response or false if the client is not authenticated.
59	 *
60	 * @since   3.2.0
61	 */
62	public function getComments($post, $limit = 0, $offset = 0, $until = null, $since = null)
63	{
64		return $this->getConnection($post, 'comments', '', $limit, $offset, $until, $since);
65	}
66
67	/**
68	 * Method to comment on a post. Requires authentication and publish_stream permission
69	 *
70	 * @param   string  $post     The post id.
71	 * @param   string  $message  The comment's text.
72	 *
73	 * @return  mixed   The decoded JSON response or false if the client is not authenticated.
74	 *
75	 * @since   3.2.0
76	 */
77	public function createComment($post, $message)
78	{
79		// Set POST request parameters.
80		$data['message'] = $message;
81
82		return $this->createConnection($post, 'comments', $data);
83	}
84
85	/**
86	 * Method to delete a comment. Requires authentication and publish_stream permission
87	 *
88	 * @param   string  $comment  The comment's id.
89	 *
90	 * @return  boolean Returns true if successful, and false otherwise.
91	 *
92	 * @since   3.2.0
93	 */
94	public function deleteComment($comment)
95	{
96		return $this->deleteConnection($comment);
97	}
98
99	/**
100	 * Method to get post's likes. Requires authentication and read_stream permission.
101	 *
102	 * @param   string   $post    The post id.
103	 * @param   integer  $limit   The number of objects per page.
104	 * @param   integer  $offset  The object's number on the page.
105	 * @param   string   $until   A unix timestamp or any date accepted by strtotime.
106	 * @param   string   $since   A unix timestamp or any date accepted by strtotime.
107	 *
108	 * @return  mixed   The decoded JSON response or false if the client is not authenticated.
109	 *
110	 * @since   3.2.0
111	 */
112	public function getLikes($post, $limit = 0, $offset = 0, $until = null, $since = null)
113	{
114		return $this->getConnection($post, 'likes', '', $limit, $offset, $until, $since);
115	}
116
117	/**
118	 * Method to like a post. Requires authentication and publish_stream permission
119	 *
120	 * @param   string  $post  The post id.
121	 *
122	 * @return  boolean Returns true if successful, and false otherwise.
123	 *
124	 * @since   3.2.0
125	 */
126	public function createLike($post)
127	{
128		return $this->createConnection($post, 'likes');
129	}
130
131	/**
132	 * Method to unlike a post. Requires authentication and publish_stream permission
133	 *
134	 * @param   string  $post  The post id.
135	 *
136	 * @return  boolean Returns true if successful, and false otherwise.
137	 *
138	 * @since   3.2.0
139	 */
140	public function deleteLike($post)
141	{
142		return $this->deleteConnection($post, 'likes');
143	}
144}
145