Merge pull request #1128 from nupplaphil/bug/twitter_timeout
Catch Twitter Exceptions
This commit is contained in:
commit
050b46139b
1 changed files with 24 additions and 20 deletions
|
@ -495,26 +495,30 @@ function twitter_action(App $a, $uid, $pid, $action)
|
||||||
|
|
||||||
Logger::debug('before action', ['action' => $action, 'pid' => $pid, 'data' => $post]);
|
Logger::debug('before action', ['action' => $action, 'pid' => $pid, 'data' => $post]);
|
||||||
|
|
||||||
switch ($action) {
|
try {
|
||||||
case 'delete':
|
switch ($action) {
|
||||||
// To-Do: $result = $connection->post('statuses/destroy', $post);
|
case 'delete':
|
||||||
$result = [];
|
// To-Do: $result = $connection->post('statuses/destroy', $post);
|
||||||
break;
|
$result = [];
|
||||||
case 'like':
|
break;
|
||||||
$result = $connection->post('favorites/create', $post);
|
case 'like':
|
||||||
if ($connection->getLastHttpCode() != 200) {
|
$result = $connection->post('favorites/create', $post);
|
||||||
Logger::warning('Unable to create favorite', ['result' => $result]);
|
if ($connection->getLastHttpCode() != 200) {
|
||||||
}
|
Logger::warning('Unable to create favorite', ['result' => $result]);
|
||||||
break;
|
}
|
||||||
case 'unlike':
|
break;
|
||||||
$result = $connection->post('favorites/destroy', $post);
|
case 'unlike':
|
||||||
if ($connection->getLastHttpCode() != 200) {
|
$result = $connection->post('favorites/destroy', $post);
|
||||||
Logger::warning('Unable to destroy favorite', ['result' => $result]);
|
if ($connection->getLastHttpCode() != 200) {
|
||||||
}
|
Logger::warning('Unable to destroy favorite', ['result' => $result]);
|
||||||
break;
|
}
|
||||||
default:
|
break;
|
||||||
Logger::warning('Unhandled action', ['action' => $action]);
|
default:
|
||||||
$result = [];
|
Logger::warning('Unhandled action', ['action' => $action]);
|
||||||
|
$result = [];
|
||||||
|
}
|
||||||
|
} catch (TwitterOAuthException $twitterOAuthException) {
|
||||||
|
Logger::warning('Unable to communicate with twitter', ['action' => $action, 'data' => $post, 'code' => $twitterOAuthException->getCode(), 'exception' => $twitterOAuthException]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::info('after action', ['action' => $action, 'result' => $result]);
|
Logger::info('after action', ['action' => $action, 'result' => $result]);
|
||||||
|
|
Loading…
Reference in a new issue