subscribing to a tag with python-instagram API in python failing
Question: I'm trying to subscribe to a hashtag using the python-instagram wrapper for
python. I have previously used cURL to perform the authentication handshake
and it worked fine. However, I would like to use all the wrapper
functionality.

    
    
    from instagram import client, subscriptions
    from flask import Flask, request, render_template, session, redirect, abort, flash,     jsonify
    
    app = Flask(__name__)
    
    api = client.InstagramAPI(client_id="", client_secret="")
    
    callback_url = 'http://localhost.com:515'
    api.create_subscription(object='tag',object_id='bacon', aspect='media', callback_url=callback_url)
    
    @app.route('/', methods=['GET'])
    def handshake():
    code = request.args.get('hub.challenge')
    if code:
        return code 
    
    if __name__ == '__main__':
        app.debug = True
    app.run(host='localhost.com',port=515)
    

The error I get is: Traceback (most recent call last):

    
    
      File "test.py", line 10, in <module>
        api.create_subscription(object='tag',object_id='bacon', aspect='media', callback_url=callback_url)
      File "/usr/local/lib/python2.7/dist-packages/instagram/bind.py", line 152, in _call
        return method.execute()
      File "/usr/local/lib/python2.7/dist-packages/instagram/bind.py", line 144, in execute
        content, next = self._do_api_request(url, method, body, headers)
      File "/usr/local/lib/python2.7/dist-packages/instagram/bind.py", line 100, in _do_api_request
        raise InstagramClientError('Unable to parse response, not valid JSON.')
    instagram.bind.InstagramClientError: Unable to parse response, not valid JSON.
    

When I remove the create_subscription line it seems to be fine, but the
create_subscription method does something strange and I can't figure out what.
The end goal is to subscribe to the tag and receive new pictures posted with
the tag.


Answer: This can be due to various issues:

  1. Make sure your callback_url is up and available for remote hosts

  2. Debug your handshake() and make sure you return the value (put prints)

  3. Debug your /usr/local/lib/python2.7/dist-packages/instagram/bind.py and see the response with error message, this can be the answer))

  4. Make your handshake() to accept POST from instagram

  5. probably you should use authenticated api in this case

