Capturing get request which is delivered in URL - flutter

HI guys i am new to flutter and trying to build app on the rest API which returns a redirection URL in response for payment purpose, and after completion of the payment it provides a call back on the return URL that i have passed in the request can any one help me to figure out how can i route to the return URL after completing my web view process as i cannot find any url scheme for the return part so.
Sample Request API:
Request
{
"client_id": "abcd",
"redirection_url": "{return URL that is passed to capture the transaction response.}",
"amount": 300,
"order_id": "dsdsassddddddd3"
}
Created an app just want to handle the Query param that are returned to certain URL on webview.

From my experience, you may need to use WebHooks as the server has no way of just responding unless you configure a webhook. Look at Stripe for example https://stripe.com/docs/webhooks

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"}}]}]}

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

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

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

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/

Giving a redirect url parameter when sending an app generated request to a facebook user

I am sending an app generated request to a user(already authorized the app) by calling the below js function
function send_app_request(){
FB.api( "/" + '<TO-USER-ID>' + "/apprequests", "POST", {
message: "Custom Request for you!",
title: "Sample title",
access_token: "<MY-APP-ACCESS-TOKEN>"
}, function(response) {
alert(response.toSource());
console.log(response);
});
}
The script is working fine, and when the user clicks on the the app icon(with the red notification), at the top right corner of the canvas, he gets redirected to ther app's index page(apps.facebook.com/MY-APP), which is also fine. My question is, what parameter should I add in my FB.api call so that the user gets redirected to my desired app url(eg: apps.facebook.com/MY-APP/show-article/?article_id=5) instead of the index url.
Requests always direct user to your application canvas.
Citing Requests documentation:
Requests are only available for Canvas apps, not websites, as accepting a request will direct the user to the Canvas Page URL of the app that sent the Request.
Possible solution will be addition of desired URL within Request data property and once user land on your Canvas URL with requests_ids passed in URL arguments, read those requests and decide based on data property where user should be redirected.
data
Optional, additional data you may pass for tracking. This will be stored as part of the request objects created. The maximum length is 255 characters.
Update:
To get the data assigned with application/user request fetch it from Graph API:
https://graph.facebook.com/<REQUEST_OBJECT_ID>_<USER_ID>?access_token=APP_ACCESS_TOKEN