http://www.perlmonks.org?node_id=1209039

igoryonya has asked for the wisdom of the Perl Monks concerning the following question:

I need to have some, at least minimal example of an instagram client. I can't figure out how to authenticate to it.
I registered client_id and client_secret @ https://www.instagram.com/developer/clients/manage/
I did:
use API::Instagram; print "test API::Intagram\n"; my $instagram = API::Instagram->new({ client_id => '32symbol_hash_key_cid', client_secret => '32symbol_hash_key_cs', redirect_uri => 'http://kutkhtravel.com/' }); printf "auth_url: %s\n", $instagram->get_auth_url; my $code = "I didn't find in documentation, what is this code, and how + do I get it"; $instagram->code($code); my $access_token = $instagram->get_access_token; $instagram->access_token($access_token); #Then, I guess, I can use other fetures, such as reading posts, etc., +but I don't get to this point
I tried, in place of code to use $instagram->get_auth_url, then I manually went to the generated "get_auth_url", authenticated there, then got token manually, and used it in $access_token var. Didn't help me any. I don't understand, maybe I am doing things in the wrong order. I don't really understand how to do it correctly. POD is of no help.
On Search engines, trying to search for API::Instagram examples or perl instagram client, didn't find anything useful, where I could peek inside of code to figure out, what's my problem.

All I get for now is an error:

Use of uninitialized value $s in substitution (s///) at /usr/local/sha +re/perl/5.22.1/Furl/HTTP.pm line 202. Use of uninitialized value $v in concatenation (.) or string at /usr/l +ocal/share/perl/5.22.1/Furl/HTTP.pm line 204. malformed JSON string, neither tag, array, object, number, string or a +tom, at character offset 0 (before "<!DOCTYPE html>\n<!-...") at /usr +/local/share/perl/5.22.1/API/Instagram.pm line 200.

Replies are listed 'Best First'.
Re: Can't get API::Instagram to work
by NetWallah (Canon) on Feb 13, 2018 at 05:37 UTC
    The code you posted does not compile, because "didn't" contains an embedded quote.
    Please post code you actually tested.

    The documentation for the Instagram 'code' related to authorization is at
    https://www.instagram.com/developer/authentication/ , under "Receiving an access_token".

    The API::Instagram module's documentation points you to to that URL: "See http://instagr.am/developer/register/ for details.".

    UPDATE: Typo corrected. Thanks, AnomalousMonk.

                    Python is a racist language what with it's dependence on white space!

      because "didn't" I fixed it.
      I was here:
      https://www.instagram.com/developer/authentication/
      and hree:
      http://instagr.am/developer/register/
      before I've posted my question and I've mentioned about it in my question.
      with /register/, I've got 'client_id and client_secret and set it up in object creation, as I mentioned in code sample
      /authentication/, I've read, but it doesn't explain the API::Instagram perl library. 'code' explanation is very vague in both places.
      I didn't find how to get 'code', by using library. I did flollow an $instagram->get_auth_url (with the browser), just to find out, if there will be the 'code', and had to click the 'authenticate' button, then it opened a page with JSON code, where it, had 'code' value. I assumed, that that 'code' was the one, that I needed to use in $instagram->code(), so, I've tried to insert the code, copied from that JSON page here: $instagram->code('copied_code'), but it didn't do anything to solve my issue. Also, even if if would, wouldn't if defy th e porpuse of library. I figure, this is module's job to gather that 'code'.

        The code you have posted seems to be a mish mash of the code from the modules synopsis, and different parts of the documentation.

        my $code = "I didn't find in documentation, what is this code, and how + do I get it"; $instagram->code($code);

        Both the instagram docs and the example code for the new constructor show how to specify the response type, which I suggest you try:

        use API::Instagram; my $instagram = API::Instagram->new({ client_id => 'xxxxxxxxxx', client_secret => 'xxxxxxxxxx', redirect_uri => 'http://localhost', scope => 'basic', response_type => 'code' granty_type => 'authorization_code', }); print $instagram->get_auth_url;

        In fact the lines following your attempt match those that follow this type of usage.

Re: Can't get API::Instagram to work
by Your Mother (Archbishop) on Feb 24, 2018 at 06:18 UTC

    See also–

    The Instagram API Platform will be deprecated beginning in July 2018. For full details please see developer blog link. For applications that support Instagram business profiles, learn more about our Instagram Graph API.