Skip to content

Commit

Permalink
cleaner error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkingorg committed May 21, 2012
1 parent 0ed01cb commit 0aceba8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/social/service/twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ public function aggregation_row($type, $item, $username, $id) {
* @return string
*/
public function tweet_url_to_id($url) {
if (substr($url, 0, 4) != 'http' || strpos($url, '/') === false) {
return '';
}
$url = explode('/', $url);
return end($url);
}
Expand All @@ -375,10 +378,7 @@ public function import_tweet_by_url($post_id, $url) {
$invalid = false;
$id = $this->tweet_url_to_id($url);
if (!empty($id) and !$this->is_original_broadcast($post, $id)) {
Social::log('Importing tweet. -- ID: :id -- URL: :url', array(
'id' => $id,
'url' => implode('/', $url)
));
Social::log('Importing tweet. -- ID: :id -- URL: :url');
$url = 'http://api.twitter.com/1/statuses/show.json?id='.$id;
$request = wp_remote_get($url);
if (!is_wp_error($request)) {
Expand Down

0 comments on commit 0aceba8

Please sign in to comment.