Skip to content

Commit

Permalink
Fix user agent on timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrimaud committed Aug 2, 2022
1 parent 81b5162 commit c2e5d62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
8 changes: 5 additions & 3 deletions src/Instagram/Transport/TimelineDataFeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use GuzzleHttp\Exception\ClientException;
use Instagram\Exception\InstagramFetchException;
use Instagram\Utils\Endpoints;
use Instagram\Utils\UserAgentHelper;
use Instagram\Utils\OptionHelper;

class TimelineDataFeed extends AbstractDataFeed
{
Expand Down Expand Up @@ -52,7 +52,8 @@ public function fetchDataNewFeedPostExist(): array

$options = [
'headers' => [
'user-agent' => UserAgentHelper::AGENT_DEFAULT,
'user-agent' => OptionHelper::$USER_AGENT,
'accept-language' => OptionHelper::$LOCALE,
'x-csrftoken' => $csrfToken,
'x-ig-app-id' => self::IG_APP_ID,
],
Expand Down Expand Up @@ -99,7 +100,8 @@ public function fetchDataTimelineFeed(string $maxId = null): array

$options = [
'headers' => [
'user-agent' => UserAgentHelper::AGENT_DEFAULT,
'user-agent' => OptionHelper::$USER_AGENT,
'accept-language' => OptionHelper::$LOCALE,
'x-csrftoken' => $csrfToken,
'x-ig-app-id' => self::IG_APP_ID,
],
Expand Down
10 changes: 2 additions & 8 deletions tests/TimelineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@

namespace Instagram\Tests;

use GuzzleHttp\{Client, Cookie\CookieJar, Cookie\SetCookie, Handler\MockHandler, HandlerStack, Psr7\Response};
use GuzzleHttp\{Client, Handler\MockHandler, HandlerStack, Psr7\Response};
use Instagram\Api;

use Instagram\Auth\Session;
use Instagram\Exception\InstagramFetchException;
use Instagram\Model\Hashtag;
use Instagram\Model\Media;
use Instagram\Model\Profile;
use Instagram\Model\Reels;
use Instagram\Model\User;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;

Expand All @@ -36,14 +32,12 @@ public function testValidTimelineFetch()

$api->login('username', 'password');

/** @var TimelineFeed $timelineFeed */
$timelineFeed = $api->getTimeline();

$this->assertCount(12, $timelineFeed->getTimeline());
$this->assertTrue($timelineFeed->hasMoreTimeline());
$this->assertSame('KGEAReU-f8agKifHBbQo8T4qJ4yFuozqEConTT6FHc4VKifY8SaNeHQqJ99NuNQaGConYrO-huzAKicjvhc_PzEqJySfsjT-PionLboxQ5wiKyeuQb8y5Z8qJzZWMDYKFionFsr24sCKYEYCKQQZBCIA', $timelineFeed->getMaxId());

/** @var Timeline $firstTimeline */
$firstTimeline = current($timelineFeed->getTimeline());

$this->assertSame("carousel", $firstTimeline->getType());
Expand Down

0 comments on commit c2e5d62

Please sign in to comment.