Skip to content

Commit

Permalink
Don't truncate tweets, now that some entities don't count towards 140…
Browse files Browse the repository at this point in the history
… chars.
  • Loading branch information
icculus committed Jan 3, 2017
1 parent 6643574 commit d8d8d43
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions cachetweets.php
Expand Up @@ -101,8 +101,14 @@ function embed_img_url($mediaurl)
/* If method is set change API call made. Test is called by default. */
$content = $connection->get('account/verify_credentials');

$data = $connection->get('statuses/user_timeline', array('screen_name' => TWITTER_USERNAME, 'count' => '2000', 'include_entities' => 'true', 'include_rts' => 'true', 'since_id' => $maxtweet));
if (isset($data->errors))
$data = $connection->get('statuses/user_timeline', array('screen_name' => TWITTER_USERNAME, 'count' => '2000', 'include_entities' => 'true', 'include_rts' => 'true', 'since_id' => $maxtweet, 'tweet_mode' => 'extended'));
if ($data === false)
{
print("get timeline failed:\n");
print(" - HTTP connection totally failed. Network burp?\n");
exit(1);
}
else if (isset($data->errors))
{
print("get timeline failed:\n");
foreach ($data->errors as $err)
Expand All @@ -117,7 +123,7 @@ function embed_img_url($mediaurl)
if ($getfromargv)
{
$id = $tweet;
$tweet = $connection->get('statuses/show', array('id' => $id, 'include_entities' => 'true'));
$tweet = $connection->get('statuses/show', array('id' => $id, 'include_entities' => 'true', 'tweet_mode' => 'extended'));
if (isset($tweet->errors))
{
print("get tweet $id failed:\n");
Expand All @@ -138,11 +144,16 @@ function embed_img_url($mediaurl)
continue;
}

if (isset($tweet->full_text))
{
$tweet->text = $tweet->full_text;
unset($tweet->full_text);
}

$origtweet = $tweet;
if (isset($tweet->retweeted_status))
$tweet = $tweet->retweeted_status;


unset($in_reply_to_name);
$mediahtml = '';
$text = isset($tweet->origtext) ? $tweet->origtext : $tweet->text;
Expand Down

0 comments on commit d8d8d43

Please sign in to comment.