viralvaghela / flutter_insta

Package to get details of the Instagram user and download reels video.
https://pub.dev/packages/flutter_insta
MIT License
61 stars 39 forks source link

[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: FormatException: Unexpected character (at character 1) #13

Open DheCastro opened 3 years ago

DheCastro commented 3 years ago

I'm getting this error, using version 1.0.4 of the package. I managed to fix it locally, but from what I saw it looks like it has already been fixed. I would like to clear that doubt.

If it hasn't been fixed, I would like to help.

Spidy-crypto commented 3 years ago

@DheCastro
I got this error. That's why i can't build the application. Can you please help me with this. :)

devon2018 commented 3 years ago

Getting the same error with version 0.1.4 think it could be a request throttling error from instagram is it worked the first few times i tried and then i started getting this issue.

DavideM12 commented 3 years ago

Yes, I have the same error with version 0.1.4. It work only for few times. Now this error. Can you fix it?

yusuftogtay commented 3 years ago

User_token does not exist in the api connection used. Instagram only allows a few shows. When I examine the code in the library, there is no auth key or user_token. I am thinking of reviewing the Instagram Api documentation and making a contribution.

DavideM12 commented 3 years ago

The old public API is deprecated (on Oct 2020). We should use the oEmbed API. It seems we have to do something like https ://graph.facebook.com/v10.0/instagram_oembed?url=https ://www.instagram.com/p/abc/&html&access_token=12345

noelli commented 3 years ago

Haven't looked into the Packages' code so far but it seems we have to add the following to eliminate such request limitations:

  1. Facebook Developer Tokens
  2. Authentication for Instagram Users to get access_tokens and view details of private Profiles

According to this: Instagram Basic Display API

@yusuftogtay are you already on it? Maybe i would look into it too if i find time. @viralvaghela would you consider merging a pr with these changes? Or do you have another scope for this package?

viralvaghela commented 3 years ago

Hello, I have looked into package code, and that public API is still working fine Screenshot (7)

DavideM12 commented 3 years ago

@viralvaghela Yes, it's true. But after few requests from the app where we have implemented your package, we cannot get the information anymore. It seems due to new Instagram policy about API

noelli commented 3 years ago

Yes, that still works.

But Instagram has a limitation for, i believe 100 Requests per hour. It depends on the type of App one is developing if that is enough.

But while developing, where hot reload may be triggering alot of requests that limit is reached very quickly. Maybe a clear Error Exception or a note in the Readme would be enough, so that new devs using the package remember to not trigger getProfileData() on each widget build but instead i.E. on App open and then on manual reload.

viralvaghela commented 3 years ago

Hi @DavideM12 , if you want you can implement oEmbed API and contribute to this package :)

DavideM12 commented 3 years ago

Thank you @viralvaghela but I don't have enough time right now. I'm busy with my full-time job and other small project :(

ValentinAhrend commented 3 years ago

Hello! I had a similar problem while programming a instagram bot. When running the url in Chrome, with all your own data, it will work, but if you run it with Postman or in Tor (without your data, cookies), it will send you to the log in view. How to solve it? I just collected the cookies of my Chrome Browser and implemented it in the request.

So I checked which cookies are needed and found out, that only the sessionId, rur and shbid are needed. rur=FTW; shbid=480

The sessionId is almost unique, but sending the same again, does not produce any damage.

ValentinAhrend commented 3 years ago

@viralvaghela could you edit the getProfileData method to something like this: Future<void> getProfileData(String username, String sessionId) async { var res = await http.get(Uri.encodeFull(url + username + "/?__a=1"), headers: {"Cookie": "rur=FTW; shbid=480; sessionid="+sessionId}); var data = json.decode(res.body); var graphql = data['graphql']; var user = graphql['user']; var biography = user['biography']; _bio = biography; var myfollowers = user['edge_followed_by']; var myfollowing = user['edge_follow']; _followers = myfollowers['count'].toString(); _following = myfollowing['count'].toString(); _website = user['external_url']; _imgurl = user['profile_pic_url_hd']; _feedImagesUrl = user['edge_owner_to_timeline_media']['edges'].map<String>((image) => image['node']['display_url'] as String).toList(); this._username=username; }

The change is in 2nd line

ValentinAhrend commented 3 years ago

This solved the issue for me...

deepss1 commented 3 years ago

@ValentinAhrend

Thank you for sharing this.

However can you please share from where do you get the Session ID ?

Can it be generated Client Side or has to be a Instagram Server Side generated Session ID ?

Thanks, Deep

ValentinAhrend commented 3 years ago

@deepss1 I received the sessionId using a heroku spring boot application, that uses selenium to login into Instagram and then getting the cookie. You need a logged in account to get this cookie. For me heroku web server was the best solution, because it is free. The users tries to use the currently uploaded sessionId and if it does not work, the sessionId will be updated. The sessionId is available for multiple tries.

deepss1 commented 3 years ago

@ValentinAhrend

Thanks for the explanation.

So did you use a headless browser ? Can you share the Heroku code with me ?

It did be great if you can so I will not have to troubleshoot Selenium and can focus on better things on the platform I will be working on.

Thanks mate

ValentinAhrend commented 3 years ago

@deepss1 I made a repo about it. @ProjectAdApp is basically me, so here: https://github.com/ProjectAdApp/isdp I deleted some stuff for security reasons. No Problem!

chaudharyjatin115 commented 2 years ago

hey i just wanted to download some reels in my app and faced the same error is it fixed or do i need to help?

SeanOThomas commented 2 years ago

It seems like each network IP is limited X number of requests. Have we confirmed that it's 100 requests? Anyone come up with a workaround?

chaudharyjatin115 commented 2 years ago

oh could you please help me find some docs related to api?

DavideM12 commented 2 years ago

oh could you please help me find some docs related to api?

I think this could be good: https://developers.facebook.com/docs/instagram-basic-display-api/getting-started

chaudharyjatin115 commented 2 years ago

thanks for the help

mehbooburrehman commented 2 years ago

hello ! how did you fix it ? can you please help ?

UmangKaklotar commented 1 year ago

from where i will get session id??