Browse Source

don't use twitter bio URL as author URL

pull/78/head
Aaron Parecki 5 years ago
parent
commit
5418072704
No known key found for this signature in database GPG Key ID: 276C2817346D6056
2 changed files with 4 additions and 16 deletions
  1. +2
    -14
      lib/XRay/Formats/Twitter.php
  2. +2
    -2
      tests/TwitterTest.php

+ 2
- 14
lib/XRay/Formats/Twitter.php View File

@ -65,7 +65,7 @@ class Twitter extends Format {
'name' => null,
'nickname' => null,
'photo' => null,
'url' => null
'url' => null,
]
);
$refs = [];
@ -226,19 +226,7 @@ class Twitter extends Format {
else
$author['name'] = $profile->screen_name;
if($profile->url) {
if(property_exists($profile, 'entities')) {
if($profile->entities->url->urls[0]->expanded_url)
$author['url'] = $profile->entities->url->urls[0]->expanded_url;
else
$author['url'] = $profile->entities->url->urls[0]->url;
} else {
$author['url'] = $profile->url;
}
}
else {
$author['url'] = 'https://twitter.com/' . $profile->screen_name;
}
$author['url'] = 'https://twitter.com/' . $profile->screen_name;
$author['photo'] = $profile->profile_image_url_https;

+ 2
- 2
tests/TwitterTest.php View File

@ -36,7 +36,7 @@ class TwitterTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('entry', $data['data']['type']);
$this->assertEquals('aaronpk dev', $data['data']['author']['name']);
$this->assertEquals('pkdev', $data['data']['author']['nickname']);
$this->assertEquals('https://aaronparecki.com/', $data['data']['author']['url']);
$this->assertEquals('https://twitter.com/pkdev', $data['data']['author']['url']);
$this->assertEquals('Portland, OR', $data['data']['author']['location']);
$this->assertEquals('Dev account for testing Twitter things. Follow me here: https://twitter.com/aaronpk', $data['data']['author']['bio']);
$this->assertEquals('https://pbs.twimg.com/profile_images/638125135904436224/qd_d94Qn_normal.jpg', $data['data']['author']['photo']);
@ -47,7 +47,7 @@ class TwitterTest extends PHPUnit_Framework_TestCase {
$data = $this->parse(['url' => $url, 'body' => $json]);
$this->assertEquals('http://agiletortoise.com', $data['data']['author']['url']);
$this->assertEquals('https://twitter.com/agiletortoise', $data['data']['author']['url']);
}
public function testBasicTestStuff() {

Loading…
Cancel
Save