【问题标题】:Get all user medias - Instagram获取所有用户媒体 - Instagram
【发布时间】:2017-03-09 23:51:30
【问题描述】:

我可以使用以下代码通过公共 API 获取 Instagram 照片(见 How to get all images of hashtag in Instagram without API?

<?php

$baseUrl = 'https://www.instagram.com/explore/tags/girls/?__a=1';
$url = $baseUrl;

while(1) {
    $json = json_decode(file_get_contents($url));
    print_r($json->tag->media->nodes);
    if(!$json->tag->media->page_info->has_next_page) break;
    $url = $baseUrl.'&max_id='.$json->tag->media->page_info->end_cursor;
}

但是,此代码仅返回给我 95 个媒体,即使用户有 1000+ 个媒体(任何用户)

有什么问题吗?

谢谢

【问题讨论】:

  • 将所有媒体发送给您的开销成本对于 instagram 来说是不值得的。我认为 95 应该足够了,但应该有一种分页方式。你知道他是怎么得到那个链接的吗,我以前从未见过。
  • 嗯...我去看看。谢谢:)

标签: php instagram instagram-api


【解决方案1】:

你为什么不用instagram-php-scraper

您可以通过composer 安装它。在您的服务器上创建一个新目录并在您的控制台上键入以下内容:

composer require raiym/instagram-php-scraper

然后简单地使用:

<?php
require 'vendor/autoload.php';
use InstagramScraper\Instagram;
$medias = Instagram::getMediasByTag('pedro', 200);
header('Content-Type: application/json');
echo json_encode($medias);

检查所有可用的方法:

https://github.com/postaddictme/instagram-php-scraper/blob/master/README.md

【讨论】:

  • 我去看看。谢谢:)
猜你喜欢
  • 2012-06-08
  • 2017-06-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多