mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-22 08:23:43 +00:00
Handle exception when posting pictures to twitter
This commit is contained in:
parent
5152eb4cd4
commit
c7aac4178c
1 changed files with 23 additions and 16 deletions
|
@ -548,7 +548,7 @@ function twitter_post_hook(App $a, &$b)
|
||||||
|
|
||||||
// and now tweet it :-)
|
// and now tweet it :-)
|
||||||
if (strlen($msg) && ($image != "")) {
|
if (strlen($msg) && ($image != "")) {
|
||||||
$connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
|
try {
|
||||||
$media = $connection->upload('media/upload', ['media' => $image]);
|
$media = $connection->upload('media/upload', ['media' => $image]);
|
||||||
|
|
||||||
$post = ['status' => $msg, 'media_ids' => $media->media_id_string];
|
$post = ['status' => $msg, 'media_ids' => $media->media_id_string];
|
||||||
|
@ -575,6 +575,13 @@ function twitter_post_hook(App $a, &$b)
|
||||||
logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']);
|
logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']);
|
||||||
Item::update(['extid' => "twitter::" . $result->id_str, 'body' => $result->text], ['id' => $b['id']]);
|
Item::update(['extid' => "twitter::" . $result->id_str, 'body' => $result->text], ['id' => $b['id']]);
|
||||||
}
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
logger('Exception when trying to send to Twitter: ' . $e->getMessage());
|
||||||
|
|
||||||
|
// Workaround: Remove the picture link so that the post can be reposted without it
|
||||||
|
$msg .= " " . $image;
|
||||||
|
$image = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($msg) && ($image == "")) {
|
if (strlen($msg) && ($image == "")) {
|
||||||
|
|
Loading…
Reference in a new issue