Reputation: 41779
I need to get user's Instagram ID which I will use to query another API. Now, what is the correct approach to this:
Check if a user has Instagram app installed on his phone. If not, send him to Google Play? Then when he installs the app and creates an account, you pull his ID from the local installation - is this possible at all?
Send a user to the web browser to login then do what? Can we get a reponse from a browser and is this pain worth of trouble?
Thanks
Upvotes: 2
Views: 2414
Reputation: 331
The easiest way, just go to https://www.instagram.com/[instagram@]/?__a=1.
And then search for id
. It will show "id":"xxxxxxxxxx"
Hope this helps.
Upvotes: 0
Reputation: 41779
You can do it two ways.
Way 1 is described on Instagram Developer under "Client-Side (Implicit) Authentication". You can fetch it from Android app using WebView
and monitoring onPageStarted
.
Way 2 is to use 3rd party library. I used android-instagram-oauth. So when you initialize and start Intagram pop-up via
InstagramApp mApp = new InstagramApp(this, CLIENT_ID, CLIENT_SECRET, CALLBACK_URL);
mApp.setListener(...);
mApp.authorize();
The class InstagramApp
will create object InstagramSession
(also part of this library) and it will save details to shared preferences.
And that's it. I hope someone will use this so you don't spend 3 days figuring this out like I did.
Upvotes: 1