【问题标题】:load image url from instagram从 instagram 加载图片 url
【发布时间】:2020-06-24 14:53:25
【问题描述】:

目前我想从 instagram url 获取图像。网址是这个

https://www.instagram.com/p/B_zZCRpB895/media/?size=t

我现在在做什么:

$image = file_get_contents("https://www.instagram.com/p/B_zZCRpB895/media/?size=t");

我在我的 AWS 服务器上运行它,但结果是登录 instagram。

<!DOCTYPE html>\n
<html lang="en" class="no-js not-logged-in client-root">\n
    <head>\n
        <meta charset="utf-8">\n
        <meta http-equiv="X-UA-Compatible" content="IE=edge">\n
\n
        <title>\n
Login • Instagram\n
</title>\n
\n
        \n
        <meta name="robots" content="noimageindex, noarchive">\n
        <meta name="apple-mobile-web-app-status-bar-style" content="default">\n
        <meta name="mobile-web-app-capable" content="yes">\n
        <meta name="theme-color" content="#ffffff">\n
        <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, viewport-fit=cover">\n
        <link rel="manifest" href="/data/manifest.json">\n
......

但是,如果我遇到本地 PC。我可以显示图像代码。有什么方法可以从 url instagram 获取图片代码?

【问题讨论】:

  • 你的意思是你的代码可以在你的本地电脑上运行,还是你的意思是你可以在你的电脑上通过浏览器访问链接?
  • 我的代码可以在我的本地 PC 上运行。但不同于 AWS 服务器
  • Instagram 可能会阻止来自不使用官方 api 的 aws 服务器的 IP 地址。也许 aws 还会在请求中发送一些不同的标头。 php.net/manual/en/function.file-get-contents.php 此链接中的示例向您展示了如何随请求发送标头。我也从 instagram 上抓取信息而不使用那里的 api,对我来说它工作正常(我将它托管在一家荷兰服务器公司上)

标签: php url instagram instar


【解决方案1】:

它认为是因为这些链接旨在提供 instagram 网站上的内容。因此,如果您想在您的网站上显示图片,则必须改用 instagram api:

这是getting started instagram api 的链接。

在您也提供身份验证令牌之后,您最有可能使用此端点:graph.facebook.com/{image id}

【讨论】:

    猜你喜欢
    • 2011-08-12
    • 2016-06-20
    • 2018-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-12
    • 1970-01-01
    相关资源
    最近更新 更多