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