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 Photo class for the Joomla Platform.
14 *
15 * @link http://developers.facebook.com/docs/reference/api/photo/
16 * @since 13.1
17 * @deprecated 4.0 Use the `joomla/facebook` package via Composer instead
18 */
19 class JFacebookPhoto extends JFacebookObject
20 {
21 /**
22 * Method to get a photo. Requires authentication and user_photos or friends_photos permission for private photos.
23 *
24 * @param string $photo The photo id.
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 getPhoto($photo)
31 {
32 return $this->get($photo);
33 }
34
35 /**
36 * Method to get a photo's comments. Requires authentication and user_photos or friends_photos permission for private photos.
37 *
38 * @param string $photo The photo id.
39 * @param integer $limit The number of objects per page.
40 * @param integer $offset The object's number on the page.
41 * @param string $until A unix timestamp or any date accepted by strtotime.
42 * @param string $since A unix timestamp or any date accepted by strtotime.
43 *
44 * @return mixed The decoded JSON response or false if the client is not authenticated.
45 *
46 * @since 13.1
47 */
48 public function getComments($photo, $limit = 0, $offset = 0, $until = null, $since = null)
49 {
50 return $this->getConnection($photo, 'comments', '', $limit, $offset, $until, $since);
51 }
52
53 /**
54 * Method to comment on a photo. Requires authentication and publish_stream permission, user_photos or friends_photos permission for private photos.
55 *
56 * @param string $photo The photo id.
57 * @param string $message The comment's text.
58 *
59 * @return mixed The decoded JSON response or false if the client is not authenticated.
60 *
61 * @since 13.1
62 */
63 public function createComment($photo, $message)
64 {
65 // Set POST request parameters.
66 $data['message'] = $message;
67
68 return $this->createConnection($photo, 'comments', $data);
69 }
70
71 /**
72 * Method to delete a comment. Requires authentication and publish_stream permission, user_photos or friends_photos permission for private photos.
73 *
74 * @param string $comment The comment's id.
75 *
76 * @return boolean Returns true if successful, and false otherwise.
77 *
78 * @since 13.1
79 */
80 public function deleteComment($comment)
81 {
82 return $this->deleteConnection($comment);
83 }
84
85 /**
86 * Method to get photo's likes. Requires authentication and user_photos or friends_photos permission for private photos.
87 *
88 * @param string $photo The photo id.
89 * @param integer $limit The number of objects per page.
90 * @param integer $offset The object's number on the page.
91 * @param string $until A unix timestamp or any date accepted by strtotime.
92 * @param string $since A unix timestamp or any date accepted by strtotime.
93 *
94 * @return mixed The decoded JSON response or false if the client is not authenticated.
95 *
96 * @since 13.1
97 */
98 public function getLikes($photo, $limit = 0, $offset = 0, $until = null, $since = null)
99 {
100 return $this->getConnection($photo, 'likes', '', $limit, $offset, $until, $since);
101 }
102
103 /**
104 * Method to like a photo. Requires authentication and publish_stream permission, user_photos or friends_photos permission for private photos.
105 *
106 * @param string $photo The photo id.
107 *
108 * @return boolean Returns true if successful, and false otherwise.
109 *
110 * @since 13.1
111 */
112 public function createLike($photo)
113 {
114 return $this->createConnection($photo, 'likes');
115 }
116
117 /**
118 * Method to unlike a photo. Requires authentication and publish_stream permission, user_photos or friends_photos permission for private photos.
119 *
120 * @param string $photo The photo id.
121 *
122 * @return boolean Returns true if successful, and false otherwise.
123 *
124 * @since 13.1
125 */
126 public function deleteLike($photo)
127 {
128 return $this->deleteConnection($photo, 'likes');
129 }
130
131 /**
132 * Method to get the Users tagged in the photo. Requires authentication and user_photos or friends_photos permission for private photos.
133 *
134 * @param string $photo The photo id.
135 * @param integer $limit The number of objects per page.
136 * @param integer $offset The object's number on the page.
137 * @param string $until A unix timestamp or any date accepted by strtotime.
138 * @param string $since A unix timestamp or any date accepted by strtotime.
139 *
140 * @return mixed The decoded JSON response or false if the client is not authenticated.
141 *
142 * @since 13.1
143 */
144 public function getTags($photo, $limit = 0, $offset = 0, $until = null, $since = null)
145 {
146 return $this->getConnection($photo, 'tags', '', $limit, $offset, $until, $since);
147 }
148
149 /**
150 * Method to tag one or more Users in a photo. $to or $tag_text required.
151 * Requires authentication and publish_stream permission, user_photos permission for private photos.
152 *
153 * @param string $photo The photo id.
154 * @param mixed $to ID of the User or an array of Users to tag in the photo: [{"id":"1234"}, {"id":"12345"}].
155 * @param string $tag_text A text string to tag.
156 * @param integer $x x coordinate of tag, as a percentage offset from the left edge of the picture.
157 * @param integer $y y coordinate of tag, as a percentage offset from the top edge of the picture.
158 *
159 * @return boolean Returns true if successful, and false otherwise.
160 *
161 * @since 13.1
162 */
163 public function createTag($photo, $to = null, $tag_text = null, $x = null, $y = null)
164 {
165 // Set POST request parameters.
166 if (is_array($to))
167 {
168 $data['tags'] = $to;
169 }
170 else
171 {
172 $data['to'] = $to;
173 }
174
175 if ($tag_text)
176 {
177 $data['tag_text'] = $tag_text;
178 }
179
180 if ($x)
181 {
182 $data['x'] = $x;
183 }
184
185 if ($y)
186 {
187 $data['y'] = $y;
188 }
189
190 return $this->createConnection($photo, 'tags', $data);
191 }
192
193 /**
194 * Method to update the position of the tag for a particular Users in a photo.
195 * Requires authentication and publish_stream permission, user_photos permission for private photos.
196 *
197 * @param string $photo The photo id.
198 * @param string $to ID of the User to update tag in the photo.
199 * @param integer $x x coordinate of tag, as a percentage offset from the left edge of the picture.
200 * @param integer $y y coordinate of tag, as a percentage offset from the top edge of the picture.
201 *
202 * @return boolean Returns true if successful, and false otherwise.
203 *
204 * @since 13.1
205 */
206 public function updateTag($photo, $to, $x = null, $y = null)
207 {
208 // Set POST request parameters.
209 $data['to'] = $to;
210
211 if ($x)
212 {
213 $data['x'] = $x;
214 }
215
216 if ($y)
217 {
218 $data['y'] = $y;
219 }
220
221 return $this->createConnection($photo, 'tags', $data);
222 }
223
224 /**
225 * Method to get the album-sized view of the photo. Requires authentication and user_photos or friends_photos permission for private photos.
226 *
227 * @param string $photo The photo id.
228 * @param boolean $redirect If false this will return the URL of the picture without a 302 redirect.
229 *
230 * @return string URL of the picture.
231 *
232 * @since 13.1
233 */
234 public function getPicture($photo, $redirect = true)
235 {
236 $extra_fields = '';
237
238 if ($redirect == false)
239 {
240 $extra_fields = '?redirect=false';
241 }
242
243 return $this->getConnection($photo, 'picture', $extra_fields);
244 }
245 }
246