Permalink
Browse files

Got in-reply-to twitter status ID discovery working

  • Loading branch information...
1 parent 76ab853 commit d851ca6db00038be4c0c044c12838002914acf10 @barnabywalters committed Aug 29, 2013
Showing with 6 additions and 6 deletions.
  1. +5 −5 BarnabyWalters/Posse/Helpers.php
  2. +1 −1 tests/BarnabyWalters/Posse/HelpersTest.php
@@ -55,16 +55,16 @@ public static function prepareForTwitter($text, $url = null, $inReplyTo = null)
if (!empty($inReplyTo)) {
if (is_string($inReplyTo))
$inReplyTo = [$inReplyTo];
- elseif (is_array($inReplyTo) and isset($inReplyTo['type']))
- $inReplyTo = isset($inReplyTo['properties']['syndication'])
- ? $inReplyTo['properties']['syndication']
- : [$inReplyTo['properties']['url']] ?: [];
+ elseif (is_array($inReplyTo))
+ $inReplyTo = isset($inReplyTo['syndication'])
+ ? $inReplyTo['syndication']
+ : @([$inReplyTo['url']] ?: []);
$tweetPattern = '/https?:\/\/twitter.com\/[a-zA-Z_]{1,20}\/status\/([0-9]*)/';
foreach ($inReplyTo as $irt):
$matches = [];
- if (preg_match($tweetPattern, $inReplyTo, $matches))
+ if (preg_match($tweetPattern, $irt, $matches))
$tweet['in_reply_to_status_id'] = $matches[1];
break;
endforeach;
@@ -78,7 +78,7 @@ public function testAddsHyphenToBlockquoteSmallPattern() {
}
public function testDerivesInReplyToIdFromObjectInReplyToSyndication() {
- $result = Helpers::prepareForTwitter('Blah.', 'http://example.com', ['syndication' => ['https://twitter.com/blah/statuses/1234567']]);
+ $result = Helpers::prepareForTwitter('Blah.', 'http://example.com', ['syndication' => ['https://twitter.com/blah/status/1234567']]);
$this->assertEquals('1234567', $result['in_reply_to_status_id']);
}

0 comments on commit d851ca6

Please sign in to comment.