TagzApp icon indicating copy to clipboard operation
TagzApp copied to clipboard

Instagram + Threads provider

Open csharpfritz opened this issue 2 years ago • 3 comments

csharpfritz avatar Aug 08 '23 14:08 csharpfritz

Did some reading around the Instagram API, and some notes which might help to speed things up if you find it useful. Apologies for the lengthy note. Meta/Instagram provides two API for interaction:

  • Graph API: This is the API for Business and Creators, not sure which category TagzApp.
  • Display API: For managing our own account so might not be useful for the hashtags usecase.

More on Graph API

  • You will need to setup an Instagram Business/Creator Account, a Facebook page connected to the same, a developer account which is a given, and a registered Facebook app (best to setup a new account and not use our personal account). Some useful docs to look at how we set this up:
  • SDKs and notes for OAuth/Access Tokens: Need to use the Facebook Developer login, Meta does not provide C#/Java SDK out of the box for OAuth. Options as found in the docs
    • OAuth 2.0, User Token Flow
    • App Access Token, on behalf flow, essentially gets a token issued using the application id and secret, it is a bearer token (Example).
    • There are other options not sure if they are relevant Client Token (it's in the URI and has an app id so I don't think its safe to use), a Page access token (to crud on Facebook Page), System User Access Token (seems like it's for ads management)

In summary for AuthN/R, I think App Access Token is the way to go but we have a wait time of 24 hours after the first test API call is done and possibly some approvals by Meta team, I am yet to try this after 24 hours. Even for the user token it is issued via an app and from the hashtag docs it seems we need to use User Token. So can @csharpfritz suggest which flow is best for this particular use case although I think we can just use the User Token Flow?

How to get Hashtags Data

  • Call ig_hashtag_search with insta user id, the query, and the fields required (just two in this case) along with the token. This will give you the id of the hashtag if available. Reference Image 2
  • You then use the ID to get top/recent media for the hashtag
  • Potential Issues: Read Limitations, highlights
    • Max of 30 unique hashtags period of 7 days rolling, so maybe we have to cache hashtags, based on how you see this growing.
    • User information even name or id is not provided so it's essentially difficult to get info on who posted. So might be empty, to begin with.
    • For CAROUSEL_ALBUM the id of the image is given so we might have to go back to get the image details in an album, also these seem to be restricted and may need additional approval haven't explored this much since I kept getting errors, docs
  • When it comes to threads it uses the same insta API internally but does not seem to expose an external API nothing in docs etc. There are some reversed Engg. GitHub project out they're not sure if they are really useable.

So few decisions on AuthN/R and limitations with the data being fetched need to be ok-ed I suppose before implementation.

manojbhargavan avatar Aug 10 '23 04:08 manojbhargavan

This is some GREAT research @manojbhargavan - thank you! I'm going to get the resources set up on the Facebook and Instagram sites so that we can build a provider

csharpfritz avatar Aug 31 '23 01:08 csharpfritz

Ouch... Meta is looking for a REAL business established and filed with the government before they grant access.

I'm going to need to delay this one

csharpfritz avatar Aug 31 '23 02:08 csharpfritz