- Timestamp:
- 02/12/11 17:47:46 (2 years ago)
- Location:
- de.easy-coding.wcf.twitter
- Files:
-
- 1 modified
- 1 moved
-
. (moved) (moved from twitter/requirements/de.easy-coding.wcf.twitter)
-
files/lib/util/TwitterUtil.class.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
de.easy-coding.wcf.twitter/files/lib/util/TwitterUtil.class.php
r769 r1285 96 96 97 97 function getRateLimit($format, $since_id = 0) { 98 $api_call = sprintf("http://twitter.com/account/rate_limit_status.%s", $format); 98 $api_call = sprintf("account/rate_limit_status.%s", $format); 99 return $this->APICall($api_call); 100 } 101 102 function getRateLimit($format, $since_id = 0) { 103 $api_call = sprintf("account/rate_limit_status.%s", $format); 104 return $this->APICall($api_call); 105 } 106 107 function getMentions($format, $since_id = 0) { 108 $api_call = sprintf("statuses/mentions.%s", $format); 99 109 return $this->APICall($api_call); 100 110 } 101 111 102 112 function getPublicTimeline($format, $since_id = 0) { 103 $api_call = sprintf(" http://twitter.com/statuses/public_timeline.%s", $format);113 $api_call = sprintf("statuses/public_timeline.%s", $format); 104 114 if ($since_id > 0) { 105 115 $api_call .= sprintf("?since_id=%d", $since_id); … … 110 120 function getFriendsTimeline($format, $id = NULL, $since = NULL) { 111 121 if ($id != NULL) { 112 $api_call = sprintf(" http://twitter.com/statuses/friends_timeline/%s.%s", $id, $format);122 $api_call = sprintf("statuses/friends_timeline/%s.%s", $id, $format); 113 123 } 114 124 else { 115 $api_call = sprintf(" http://twitter.com/statuses/friends_timeline.%s", $format);125 $api_call = sprintf("statuses/friends_timeline.%s", $format); 116 126 } 117 127 if ($since != NULL) { … … 123 133 function getUserTimeline($format, $id = NULL, $count = 20, $since = NULL) { 124 134 if ($id != NULL) { 125 $api_call = sprintf(" http://twitter.com/statuses/user_timeline/%s.%s", $id, $format);135 $api_call = sprintf("statuses/user_timeline/%s.%s", $id, $format); 126 136 } 127 137 else { 128 $api_call = sprintf(" http://twitter.com/statuses/user_timeline.%s", $format);138 $api_call = sprintf("statuses/user_timeline.%s", $format); 129 139 } 130 140 if ($count != 20) { … … 138 148 139 149 function showStatus($format, $id) { 140 $api_call = sprintf(" http://twitter.com/statuses/show/%d.%s", $id, $format);150 $api_call = sprintf("statuses/show/%d.%s", $id, $format); 141 151 return $this->APICall($api_call); 142 152 } … … 144 154 function updateStatus($format, $status) { 145 155 $status = urlencode(stripslashes(urldecode($status))); 146 $api_call = sprintf(" http://twitter.com/statuses/update.%s?status=%s", $format, $status);156 $api_call = sprintf("statuses/update.%s?status=%s", $format, $status); 147 157 return $this->APICall($api_call, true, true); 148 158 } 149 159 150 160 function getReplies($format, $page = 0) { 151 $api_call = sprintf(" http://twitter.com/statuses/replies.%s", $format);161 $api_call = sprintf("statuses/replies.%s", $format); 152 162 if ($page) { 153 163 $api_call .= sprintf("?page=%d", $page); … … 157 167 158 168 function destroyStatus($format, $id) { 159 $api_call = sprintf(" http://twitter.com/statuses/destroy/%d.%s", $id, $format);169 $api_call = sprintf("statuses/destroy/%d.%s", $id, $format); 160 170 return $this->APICall($api_call, true); 161 171 } … … 163 173 function getFriends($format, $page = 1) { 164 174 // take care of the id parameter 165 $api_call = sprintf(" http://twitter.com/statuses/friends.%s%s", $format, "?page=$page");175 $api_call = sprintf("statuses/friends.%s%s", $format, "?page=$page"); 166 176 return $this->APICall($api_call, true); 167 177 } 168 178 169 179 function getFollowers($format, $page = 1) { 170 $api_call = sprintf(" http://twitter.com/statuses/followers.%s%s", $format, "?page=$page");180 $api_call = sprintf("statuses/followers.%s%s", $format, "?page=$page"); 171 181 return $this->APICall($api_call, true); 172 182 } 173 183 174 184 function getFeatured($format) { 175 $api_call = sprintf(" http://twitter.com/statuses/featured.%s", $format);185 $api_call = sprintf("statuses/featured.%s", $format); 176 186 return $this->APICall($api_call); 177 187 } … … 179 189 function showUser($format, $id, $email = NULL) { 180 190 if ($email == NULL) { 181 $api_call = sprintf(" http://twitter.com/users/show/%s.%s", $id, $format);191 $api_call = sprintf("users/show/%s.%s", $id, $format); 182 192 } 183 193 else { 184 $api_call = sprintf(" http://twitter.com/users/show.xml?email=%s", $email);194 $api_call = sprintf("users/show.xml?email=%s", $email); 185 195 } 186 196 return $this->APICall($api_call, true); … … 188 198 189 199 function getMessages($format, $since = NULL, $since_id = 0, $page = 1) { 190 $api_call = sprintf(" http://twitter.com/direct_messages.%s", $format);200 $api_call = sprintf("direct_messages.%s", $format); 191 201 if ($since != NULL) { 192 202 $api_call .= sprintf("?since=%s", urlencode($since)); … … 202 212 203 213 function getSentMessages($format, $since = NULL, $since_id = 0, $page = 1) { 204 $api_call = sprintf(" http://twitter.com/direct_messages/sent.%s", $format);214 $api_call = sprintf("direct_messages/sent.%s", $format); 205 215 if ($since != NULL) { 206 216 $api_call .= sprintf("?since=%s", urlencode($since)); … … 217 227 function newMessage($format, $user, $text) { 218 228 $text = urlencode(stripslashes(urldecode($text))); 219 $api_call = sprintf(" http://twitter.com/direct_messages/new.%s?user=%s&text=%s", $format, $user, $text);229 $api_call = sprintf("direct_messages/new.%s?user=%s&text=%s", $format, $user, $text); 220 230 return $this->APICall($api_call, true, true); 221 231 } 222 232 223 233 function destroyMessage($format, $id) { 224 $api_call = sprintf(" http://twitter.com/direct_messages/destroy/%s.%s", $id, $format);234 $api_call = sprintf("direct_messages/destroy/%s.%s", $id, $format); 225 235 return $this->APICall($api_call, true); 226 236 } 227 237 228 238 function createFriendship($format, $id) { 229 $api_call = sprintf(" http://twitter.com/friendships/create/%d.%s", $id, $format);239 $api_call = sprintf("friendships/create/%d.%s", $id, $format); 230 240 return $this->APICall($api_call, true, true); 231 241 } 232 242 233 243 function destroyFriendship($format, $id) { 234 $api_call = sprintf(" http://twitter.com/friendships/destroy/%s.%s", $id, $format);244 $api_call = sprintf("friendships/destroy/%s.%s", $id, $format); 235 245 return $this->APICall($api_call, true, true); 236 246 } 237 247 238 248 function verifyCredentials($format = NULL) { 239 $api_call = sprintf(" http://twitter.com/account/verify_credentials%s", ($format != NULL) ? sprintf(".%s", $format) : NULL);249 $api_call = sprintf("account/verify_credentials%s", ($format != NULL) ? sprintf(".%s", $format) : NULL); 240 250 return $this->APICall($api_call, true); 241 251 } 242 252 243 253 function endSession() { 244 $api_call = " http://twitter.com/account/end_session";254 $api_call = "account/end_session"; 245 255 return $this->APICall($api_call, true); 246 256 } 247 257 248 258 function getArchive($format, $page = 1) { 249 $api_call = sprintf(" http://twitter.com/account/archive.%s", $format);259 $api_call = sprintf("account/archive.%s", $format); 250 260 if ($page > 1) { 251 261 $api_call .= sprintf("?page=%d", $page); … … 256 266 function getFavorites($format, $id = NULL, $page = 1) { 257 267 if ($id == NULL) { 258 $api_call = sprintf(" http://twitter.com/favourings.%s", $format);268 $api_call = sprintf("favourings.%s", $format); 259 269 } 260 270 else { 261 $api_call = sprintf(" http://twitter.com/favourings/%s.%s", $id, $format);271 $api_call = sprintf("favourings/%s.%s", $id, $format); 262 272 } 263 273 if ($page > 1) { … … 268 278 269 279 function createFavorite($format, $id) { 270 $api_call = sprintf(" http://twitter.com/favourings/create/%d.%s", $id, $format);280 $api_call = sprintf("favourings/create/%d.%s", $id, $format); 271 281 return $this->APICall($api_call, true); 272 282 } 273 283 274 284 function destroyFavorite($format, $id) { 275 $api_call = sprintf(" http://twitter.com/favourings/destroy/%d.%s", $id, $format);285 $api_call = sprintf("favourings/destroy/%d.%s", $id, $format); 276 286 return $this->APICall($api_call, true); 277 287 } 278 288 279 289 private function APICall($api_url, $require_credentials = false, $http_post = false) { 290 $api_url = 'http://api.twitter.com/1/'; 291 280 292 $curl_handle = curl_init(); 281 293 curl_setopt($curl_handle, CURLOPT_URL, $api_url);
