What is https://i.instagram.com/api/v1 - rest

I am digging into Instagram APIs and find out a URL https://i.instagram.com/api/v1 which used by many git repos(some are recently updated) but when I go to Instagram there is no such url available there. Can anyone guide me what is the use of this url and how I can use it because when I hit
https://i.instagram.com/api/v1/accounts/login/
by POSTMAN i got below message
{
"message": "Your version of Instagram is out of date. Please upgrade your app to log in to Instagram.",
"status": "fail",
"error_type": "needs_upgrade"
}
One more thing. I am with my friend who work in android he has done reverse engineering on a app which use for increase followers and that app is also using same endpoints and working on that app.

It's November 2021, and somehow the API https://i.instagram.com/api/v1 still works, but I believe they have changed the way you use it.
NOTE: The given information is just for educational purposes
Let's take the user/{user_id}/info endpoint of this API, which returns basic information about the user_id.
The URL with this endpoint would be
https://i.instagram.com/api/v1/users/176702683/info/
If you paste this link into your browser you'll get the following message
{"message":"useragent mismatch","status":"fail"}
This means that API must be called via mobile user-agent. read more about user-agent here
We can solve this problem by providing a mobile user-agent string.
Using python requests library
!pip install requests
import requests
URL = https://i.instagram.com/api/v1/users/176702683/info/
headers = {'User-Agent':'Instagram 76.0.0.15.395 Android (24/7.0; 640dpi; 1440x2560; samsung; SM-G930F; herolte; samsungexynos8890; en_US; 138226743)'}
# samsung mobile user-agent
response = requests.get(url, headers=headers)
print(response.json())
Output:
{
"user": {
"username": "marcelotwelve",
"pk": 176702683,
"profile_pic_url": "https://instagram.fzrh3-1.fna.fbcdn.net/v/t51.2885-19/233796637_544571223333074_8761964745157634211_n.jpg?stp=dst-jpg_s150x150\\u0026_nc_ht=instagram.fzrh3-1.fna.fbcdn.net\\u0026_nc_cat=1\\u0026_nc_ohc=Cfk2kHCxgbIAX_vgNjn\\u0026edm=AEF8tYYBAAAA\\u0026ccb=7-5\\u0026oh=00_AT-tuXbAbsIkvmJqm_akQS__UPDtEXZxZChx2lO-9Wb0FQ\\u0026oe=62A8115E\\u0026_nc_sid=a9513d"
},
"status": "ok"
}
NOTE: Please be aware of how you use it

It is actually an API, that you can only use from your phone application, thats why it say it needs upgrade. you can download an addon for chrome / firefox to switch user agents, and after that you will be able to see the content.
It's worth checking there is lots of info about any user on insa

this response is a default error caused by having no cookie set
inspect instagram, you can see a redirect first (this way they fill initial cookies set for you). copy paste it to postman and try again

Related

Problems with facebook app's web-hook [duplicate]

I am trying to install a webhook for leadgen event for my page via a facebook app. So I have:
Facebook Page where leads come from
Facebook App
Webserver where I want to save leads
App and webserver are connected well I believe. Webhook is shown at app page etc. But when I am trying to create a test lead with this tool https://developers.facebook.com/tools/lead-ads-testing I am getting a POST request with no data in it.
I was suspecting permissions problems, but I am able to check a lead from page (via leadgen_id) directly with PHP SDK and the POST request is sent from Facebook just by URL, so they don't know about tokens yet.
UPD Plain POST request to the same url (curl -d "param=value" https://..url..) works as expected.
Facebook sends webhook data as Content-Type: application/json, not as …: application/x-www-form-urlencoded (as a normal form with method=post would.)
Therefor, PHP does not populate $_POST – you need to read the raw input stream instead. That can be done using file_get_contents('php://input') – and then just apply json_decode on that data, and you’ll have a proper data structure to work with.
Facebook sends the leads data in the request body. If you are using a framework, please check if you have access to the request body.
Try using a third party intermediate service like Runscope to see the full request, it is very usef
This code works for me...
if (!empty($_REQUEST['hub_mode']) && $_REQUEST['hub_mode'] == 'subscribe' && $_REQUEST['hub_verify_token'] == "<mytoken>") {
echo $_REQUEST['hub_challenge'];
} else {
$data = json_decode(file_get_contents("php://input"), true);
file_put_contents('logFB.txt', print_r($data, true));
}
First part is for verifying webhook, second for getting data from facebook webhook.
Hope this will help...
In case you are using the django framework, you should request.body, as post data will remain empty.
def webhook_response(request):
# it will print the contents from facebook webhook response
print(request.body)
# something like the following object will print up if you are using leadgen
{"object": "page", "entry": [{"id": "0", "time": 111111111, "changes": [{"field": "leadgen", "value": {"ad_id": "444444444", "form_id": "444444444444", "leadgen_id": "444444444444", "created_time": 11111111, "page_id": "444444444444", "adgroup_id": "44444444444"}}]}]}

How to obtain the live video id of a facebook live video?

I am trying to access the live views count of a live video that is live through a Facebook Page. I am using the ID that I am obtaining from the API request {page-id}/videos/uploaded When I am using that video id and making a GET request of {video-id}?fields='live_views its showing error code of 100 with the message as:
(#100) Tried accessing nonexisting field (live_views) on node type (Video)
I have the following permissions:
'manage_pages', 'publish_pages', 'business_management', 'read_insights', 'user_videos'
I am making the GET request using user_access_token.
I am using Graph API Version 2.8.
Please let me know if I am using the wrong ID. IF yes, then how can i get the live_video_id of a live video posted in page?
To get the live views count of a video a fan page, you need:
An app created at facebook developer
A user access token (for testing, e.g. by calling https://developers.facebook.com/tools/accesstoken/)
The fan page id
With this you can call graph API in the following format:
https://graph.facebook.com/v2.8/<fan_page_id>/live_videos?access_token=<access_token>?fields=live_views
Of course, you may add more elements in fields parameter if you need more information. Here Facebook's Graph API explorer helps: https://developers.facebook.com/tools/explorer
When you add status to fields parameter, "LIVE" means, it's currently live, "VOD" means it has already finished.
If you try to implement a WebHook for it, let me now if it works. Thanks.
To get live views you need to call the api with the live video id, which you get from calling, page id can initially be either the page-id or name
"https://graph.facebook.com/v10.0/${page_id}/live_videos?access_token=${access_token}
Sample response:
{
"title": "hello world 2",
"status": "LIVE",
"embed_html": "...,
"id": "123123" // this is the live video id
},
After you have retrieved the live video id you can call this endpoint to get the live_views edge
https://graph.facebook.com/v10.0/${live_id}fields=live_views&access_token=${access_token}
sample response:
{
"live_views": 1,
"id": "123123"
}
Docs for endpoint 1: https://developers.facebook.com/docs/graph-api/reference/live-video/
Docs for endpoint 2: https://developers.facebook.com/docs/graph-api/reference/live-video/reactions#Reading
However I understand the confusion since live_views is not listed under the second endpoint as a reaction nor even is it a reaction, so either it a mistake in facebook docs or a mistake in the graph API, either the solution provided works.
Yes you do need to go through an app review to get the permission for tracking streams

Facebook returning a 206 response only from a determined server

I'm trying to post a feed using Facebook javascript API (FB.ui). When I post the feed, the image field appears empty.
Of course I've tried the URL from the example provided by facebook http://www.fbrell.com/f8.jpg and it works fine. Then I downloaded this image and uploaded to my server and tried again and got nothing.
Using the facebook debugger, the facebook example image returns a 200 message, and the same image from my server returns a 206 message, which I believe is the reason why it's not showing in the feed dialog.
This is the Graph API output from debugger:
{
"id": "530885910309390",
"url": "http://www.zx-works.com/img/f8.jpg",
"type": "website",
"title": "http://www.zx-works.com/img/f8.jpg",
"updated_time": "2013-06-01T18:48:22+0000",
"created_time": "2013-06-01T18:23:58+0000",
"is_scraped": true
}
Question is: what can possibly change from one server to another to facebook not get the image correctly? Is something I can do to fix it from my server side? It's running Apache 2.2.24. Someone runned into this problem before?
Facebook uses ipv6 to scrap your website. Is your DNS set to ipv6? Did your server controlpanel (like directadmin) allow ipv6 access?
Otherwise, contact your hosting company to answer these questions and you'll be fine!

Error with Twitter link

Yesterday I started a new app on Facebook. Today I got the message that when people copy the link to Twitter they get an error. This is what you get:
{
"error": {
"message": "Unknown path components: /your_namespace:your_action",
"type": "OAuthException",
"code": 2500
}
}
What does this mean? What could be the problem?
Are you actually sending the POST action link to Twitter? Why?
I think you misunderstood how Open Graph works. Basically, you should be the one publishing actions when users take an action using your service. You can use a server-side or a client-side language to POST request (when you click a link, your browser actually makes a GET request, not a POST) to https://graph.facebook.com/me/namespace:action?access_token=ACCESS_TOKEN&OBJECT_PATH=OBJECT_URL
Note that you need to create an app, use it to authenticate users to get the access token and also set your custom actions / objects. These will need to be approved before you can actually use them.
You should start by taking a look at the sample apps to see how they work: https://developers.facebook.com/docs/samples/

Facebook API checkins not working?

Wondering if anybody has had any problems using the facebook graph api to get checkins.
https://graph.facebook.com/me/checkins?access_token=2227470867|2.SOgfV3_Dc6iX_IzJctERXA__.3600.1292436000-666790342|UPcbXaafo7G5rd2I_7d9_LpeZFo
returns
{
"data": [
]
}
and any other ids insted of "me" return the same.
Anyone have any ideas?
Turns out you can't access the fb places api outside the US
Allright fellows,
after some tries I can shed a light to this topic, here comes the description of the solution.
You can make such requests only by authorized apps.
I implemented the flow on Android and works like a charm,
here is an example call grabbed from logs:
https://graph.facebook.com/me/checkins?format=json&sdk=android&access_token=<access_token>
important note: access token MUST have been retrieved by your application, which has permissions for
"user_checkins", "friends_checkins"
getting access token is straight forward flow, explained well in all SDKs (p.s. I'm using Facebook-AndroidSDK)