Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Instagram实时API可以';我看不到我的服务器_Python_Flask_Instagram Api - Fatal编程技术网

Python Instagram实时API可以';我看不到我的服务器

Python Instagram实时API可以';我看不到我的服务器,python,flask,instagram-api,Python,Flask,Instagram Api,我正在用Python和Flask测试Instagram实时API,每次我都会从Instagram服务器得到这样的响应: { "meta":{ "error_type":"APISubscriptionError", "code":400, "error_message":"Unable to reach callback URL \"http:\/\/my_callback_url:8543\/instagram\"." } } 请求:

我正在用Python和Flask测试Instagram实时API,每次我都会从Instagram服务器得到这样的响应:

{  
   "meta":{  
      "error_type":"APISubscriptionError",
      "code":400,
      "error_message":"Unable to reach callback URL \"http:\/\/my_callback_url:8543\/instagram\"."
   }
}
请求:

curl -F 'client_id=my_client_id...' \
     -F 'client_secret=my_client_secret...' \
     -F 'object=tag' \
     -F 'aspect=media' \
     -F 'object_id=fox' \
     -F 'callback_url=http://my_callback_url:8543/instagram' \
     https://api.instagram.com/v1/subscriptions/
这是Flask服务器的代码:

from flask import Flask
from flask import request

from instagram import subscriptions

app = Flask(__name__)

CLIENT_ID = "my_client_id..."
CLIENT_SECRET = "my_client_secret..."


def process_tag_update(update):
    print 'Received a push: ', update

reactor = subscriptions.SubscriptionsReactor()
reactor.register_callback(subscriptions.SubscriptionType.TAG, process_tag_update)


@app.route('/instagram', methods=['GET'])
def handshake():
    # GET method is used when validating the endpoint as per the Pubsubhubub protocol
    mode = request.values.get('hub.mode')
    challenge = request.values.get('hub.challenge')
    verify_token = request.values.get('hub.verify_token')
    if challenge:
        return challenge
    return 'It is not a valid challenge'

@app.route('/instagram', methods=['POST'])
def callback():
    # POST event is used to for the events notifications
    x_hub_signature = request.headers.get('X-Hub-Signature')
    raw_response = request.data
    try:
        reactor.process(CLIENT_SECRET, raw_response, x_hub_signature)
    except subscriptions.SubscriptionVerifyError:
        print 'Signature mismatch'
    return 'done'

def server():
    """ Main server, will allow us to make it wsgi'able """
    app.run(host='0.0.0.0', port=8543, debug=True)


if __name__ == '__main__':
    server()
机器有一个公共IP,端口对所有人开放。我可以从其他网络访问url

为什么Instagram无法访问我的url?有黑名单之类的吗


更新1

我用一些框架和WSGI服务器(Django、Flask、Node.js、Gunicorn、Apache)测试了相同的代码,并在GET/POST端点中测试了不同的响应,我总是得到相同的错误消息

此外,我还与Wireshark检查了在网络接口中接收到的包,并通过来自任何网络的调用获得了预期的结果。但是我在订阅请求时没有收到任何包


所以。。。这是虫子吗?由于某种原因,我的IP可能会被列入任何黑名单?

我的IP也完全一样。当我不小心重新启动路由器,得到一个不同的IP时,它工作了。这似乎确实可能是一个IP问题,
无法访问回调URL…
在这种情况下并没有真正的帮助。

我同意,有很多AWS服务器响应该API,有些不工作。Ping api.instagram.com,您将看到该域名拥有多个不同的IP。存在DNS循环,并且您不是每次都到达相同的服务器


我发现一台服务器(IP:52.6.133.72)似乎正在为订阅工作,并已将我的服务器配置为使用该服务器(通过编辑/etc/hosts文件)。不是一个可靠的解决方案。。。但它正在工作。

有同样的问题,但还没有找到任何解决方案。有时(很少)它起作用。大多数时候我都会犯和你一样的错误