FacebookBridge - fail gracefully if the user has already deleted a

linked notice on Facebook.
This commit is contained in:
Zach Copley 2010-11-22 21:40:47 +00:00
parent 2b0d1d9fc4
commit 7e6c0e542f

View File

@ -103,6 +103,7 @@ class Facebookclient
*/
static function facebookBroadcastNotice($notice)
{
common_debug('Facebook broadcast');
$client = new Facebookclient($notice);
return $client->sendNotice();
}
@ -424,12 +425,6 @@ class Facebookclient
);
return true;
break;
// @fixme: Facebook returns these 2xx permission errors sometimes
// FOR NO GOOD REASON AT ALL! It would be better to retry a few times
// over an extended period of time to instead of immediately
// disconnecting.
case 200: // Permissions error
case 250: // Updating status requires the extended permission status_update
$this->disconnect();
@ -979,6 +974,8 @@ BODY;
if (!empty($this->flink) && !empty($n2i)) {
try {
$result = $this->facebook->api(
array(
'method' => 'stream.remove',
@ -1004,15 +1001,21 @@ BODY;
$n2i->delete();
} else {
throw new FaceboookApiException(var_export($result, true));
}
} catch (FacebookApiException $e) {
common_log(
LOG_WARNING,
sprintf(
'Could not deleted Facebook item: %s for %s (%d), fbuid %d',
'Could not deleted Facebook item: %s for %s (%d), '
. 'fbuid %d - (API error: %s) item already deleted '
. 'on Facebook? ',
$n2i->item_id,
$this->user->nickname,
$this->user->id,
$this->flink->foreign_id
$this->flink->foreign_id,
$e
),
__FILE__
);
@ -1030,6 +1033,8 @@ BODY;
if (!empty($this->flink) && !empty($n2i)) {
try {
$result = $this->facebook->api(
array(
'method' => 'stream.addlike',
@ -1053,15 +1058,20 @@ BODY;
);
} else {
throw new FacebookApiException(var_export($result, true));
}
} catch (FacebookApiException $e) {
common_log(
LOG_WARNING,
sprintf(
'Could not like Facebook item: %s for %s (%d), fbuid %d',
'Could not like Facebook item: %s for %s (%d), '
. 'fbuid %d (API error: %s)',
$n2i->item_id,
$this->user->nickname,
$this->user->id,
$this->flink->foreign_id
$this->flink->foreign_id,
$e
),
__FILE__
);
@ -1079,6 +1089,8 @@ BODY;
if (!empty($this->flink) && !empty($n2i)) {
try {
$result = $this->facebook->api(
array(
'method' => 'stream.removeLike',
@ -1102,15 +1114,20 @@ BODY;
);
} else {
throw new FacebookApiException(var_export($result, true));
}
} catch (FacebookApiException $e) {
common_log(
LOG_WARNING,
sprintf(
'Could not remove like for Facebook item: %s for %s (%d), fbuid %d',
'Could not remove like for Facebook item: %s for %s '
. '(%d), fbuid %d (API error: %s)',
$n2i->item_id,
$this->user->nickname,
$this->user->id,
$this->flink->foreign_id
$this->flink->foreign_id,
$e
),
__FILE__
);