Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
album.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 Album class for the Joomla Platform.
16  *
17  * @package Joomla.Platform
18  * @subpackage Facebook
19  *
20  * @see http://developers.facebook.com/docs/reference/api/album/
21  * @since 13.1
22  */
24 {
25  /**
26  * Method to get an album. Requires authentication and user_photos or friends_photos permission for private photos.
27  *
28  * @param string $album The album 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 getAlbum($album)
35  {
36  return $this->get($album);
37  }
38 
39  /**
40  * Method to get the photos contained in this album. Requires authentication and user_photos or friends_photos permission for private photos.
41  *
42  * @param string $album The album 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 getPhotos($album, $limit = 0, $offset = 0, $until = null, $since = null)
53  {
54  return $this->getConnection($album, 'photos', '', $limit, $offset, $until, $since);
55  }
56 
57  /**
58  * Method to add photos to an album. Note: check can_upload flag first. Requires authentication and publish_stream permission.
59  *
60  * @param string $album The album id.
61  * @param string $source Path to photo.
62  * @param string $message Photo description.
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 createPhoto($album, $source, $message = null)
69  {
70  // Set POST request parameters.
71  $data = array();
72  $data[basename($source)] = '@' . realpath($source);
73 
74  if ($message)
75  {
76  $data['message'] = $message;
77  }
78 
79  return $this->createConnection($album, 'photos', $data, array('Content-Type' => 'multipart/form-data'));
80  }
81 
82  /**
83  * Method to get an album's comments. Requires authentication and user_photos or friends_photos permission for private photos.
84  *
85  * @param string $album The album id.
86  * @param integer $limit The number of objects per page.
87  * @param integer $offset The object's number on the page.
88  * @param string $until A unix timestamp or any date accepted by strtotime.
89  * @param string $since A unix timestamp or any date accepted by strtotime.
90  *
91  * @return mixed The decoded JSON response or false if the client is not authenticated.
92  *
93  * @since 13.1
94  */
95  public function getComments($album, $limit = 0, $offset = 0, $until = null, $since = null)
96  {
97  return $this->getConnection($album, 'comments', '', $limit, $offset, $until, $since);
98  }
99 
100  /**
101  * Method to comment on an album. Requires authentication and publish_stream permission.
102  *
103  * @param string $album The album id.
104  * @param string $message The comment's text.
105  *
106  * @return mixed The decoded JSON response or false if the client is not authenticated.
107  *
108  * @since 13.1
109  */
110  public function createComment($album, $message)
111  {
112  // Set POST request parameters.
113  $data = array();
114  $data['message'] = $message;
115 
116  return $this->createConnection($album, 'comments', $data);
117  }
118 
119  /**
120  * Method to delete a comment. Requires authentication and publish_stream permission.
121  *
122  * @param string $comment The comment's id.
123  *
124  * @return boolean Returns true if successful, and false otherwise.
125  *
126  * @since 13.1
127  */
128  public function deleteComment($comment)
129  {
130  return $this->deleteConnection($comment);
131  }
132 
133  /**
134  * Method to get album's likes. Requires authentication and user_photos or friends_photos permission for private photos.
135  *
136  * @param string $album The album id.
137  * @param integer $limit The number of objects per page.
138  * @param integer $offset The object's number on the page.
139  * @param string $until A unix timestamp or any date accepted by strtotime.
140  * @param string $since A unix timestamp or any date accepted by strtotime.
141  *
142  * @return mixed The decoded JSON response or false if the client is not authenticated.
143  *
144  * @since 13.1
145  */
146  public function getLikes($album, $limit = 0, $offset = 0, $until = null, $since = null)
147  {
148  return $this->getConnection($album, 'likes', '', $limit, $offset, $until, $since);
149  }
150 
151  /**
152  * Method to like an album. Requires authentication and publish_stream permission.
153  *
154  * @param string $album The album id.
155  *
156  * @return boolean Returns true if successful, and false otherwise.
157  *
158  * @since 13.1
159  */
160  public function createLike($album)
161  {
162  return $this->createConnection($album, 'likes');
163  }
164 
165  /**
166  * Method to unlike an album. Requires authentication and publish_stream permission.
167  *
168  * @param string $album The album id.
169  *
170  * @return boolean Returns true if successful, and false otherwise.
171  *
172  * @since 13.1
173  */
174  public function deleteLike($album)
175  {
176  return $this->deleteConnection($album, 'likes');
177  }
178 
179  /**
180  * Method to get the album's cover photo, the first picture uploaded to an album becomes the cover photo for the album.
181  * Requires authentication and user_photos or friends_photos permission for private photos.
182  *
183  * @param string $album The album id.
184  * @param boolean $redirect If false this will return the URL of the picture without a 302 redirect.
185  *
186  * @return string URL of the picture.
187  *
188  * @since 13.1
189  */
190  public function getPicture($album, $redirect = true)
191  {
192  $extra_fields = '';
193 
194  if ($redirect == false)
195  {
196  $extra_fields = '?redirect=false';
197  }
198 
199  return $this->getConnection($album, 'picture', $extra_fields);
200  }
201 }