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