Skip to content

Commit

Permalink
Content, retweets, and sample config
Browse files Browse the repository at this point in the history
Reposts likely don't have content of their own, so check first for the
presence of content before trying to use it.

Retweets use a [specific API
URL](abraham/twitteroauth#428 (comment))
rather than using the Tweet ID as a parameter.

Add the token endpoint to the sample config file.
  • Loading branch information
Scott Merrill committed May 17, 2018
1 parent 0e9deb5 commit f67682d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
3 changes: 3 additions & 0 deletions config.php.sample
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ $config = array(
),
),

# the IndieAuth token endpoint to use
'token_endpoint' => 'https://tokens.indieauth.com/token',

# the timezone to use for all times
'tz' => 'America/New_York',

Expand Down
11 changes: 8 additions & 3 deletions inc/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,15 @@ function create($request, $photos = []) {

# pull out just the content, so that $properties can be front matter
# NOTE: content may be in ['content'] or ['content']['html'].
if (is_array($properties['content']) && isset($properties['content']['html'])) {
$content = $properties['content']['html'];
# NOTE 2: there may be NO content!
if (isset($properties['content'])) {
if (is_array($properties['content']) && isset($properties['content']['html'])) {
$content = $properties['content']['html'];
} else {
$content = $properties['content'];
}
} else {
$content = $properties['content'];
$content = '';
}
# ensure that the properties array doesn't contain 'content'
unset($properties['content']);
Expand Down
4 changes: 2 additions & 2 deletions inc/twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ function syndicate_twitter($config, $properties, $content, $url) {
# URL of our instance of it.
if (isset($properties['repost-of'])) {
$id = get_tweet_id($properties['repost-of']);
$tweet = $t->post('statuses/retweet/', ['id' => $id]);
if (! $t->getLastHttpCode() == 200) {
$tweet = $t->post("statuses/retweet/$id");
if ($t->getLastHttpCode() != 200) {
return false;
}
return build_tweet_url($tweet);
Expand Down

0 comments on commit f67682d

Please sign in to comment.