get the user who sent application request - php

Scenario:
User A send application request to user B
User B accepts request
after accepting request, I want User A's facebook ID who actually sent request
In short I want inviting user on application request accept event of invitee user.

You can get the details on request (including creator details) by querying Graph API with ID of request (you have list of accepting request ids in request_ids parameter passed to you app canvas):
https://graph.facebook.com/REQUEST_ID
This will return details in following format (as described in requests documentation, see "Accepting an App Request / Request ID Format"):
{
"id": "REQUEST_OBJECT_ID",
"application": {
"name": "APP_DISPLAY_NAME",
"canvas_name": "APP_NAME", // This is identical to the app namespace
"namespace": "APP_NAMESPACE",
"id": "APP_ID"
},
"from": {
"name": "SENDER_USER_NAME",
"id": "SEND_USER_ID"
},
"message": "Check out this Awesome Request!",
"created_time": "2012-01-24T00:43:22+0000",
"type": "apprequest"
}

Related

Sending Json to Jira Api

I am trying to send a POST request to Jira API
Example Json
{
"fields": {
"project":
{
"key": "BAR"
},
"summary": "testttt",
"description": "Creating of an issue using project keys and issue type names using the REST API",
"issuetype": {
"name": "Bug"
},
"priority" :{
"name" : "Low"
}
}
}
I am successfully making a POST request with postman to the API but I am struggling to make this POST request with Laravel.
I made a form in HTML where the admin must write some data like summary description issuetype and priority. I am accepting the data in the back end but I am having trouble how can I build such JSON with Laravel.
As you can see here
"issuetype": {
"name": "Bug"
}
name is nested in the issutype how can I explicitly create it to be ready to send into the API

Facebook Messenger Send returns "No matching user found"

I want to send a message to a user from my server once they've finished successfully updating their payment details in a Facebook Messenger Webview, just before I close the webview window and return to the chat.
I'm sending a POST message, as defined, to https://graph.facebook.com/v2.6/me/messages?access_token=ABC In the format of:
{
"recipient": {
"id": 123456789
},
"message": {
"text": "hello, world!"
}
}
...where 123456789 is the valid Page Scoped User Id of the person I'm messaging (currently, that person is an admin of the app while we're in development).
The response I get is:
{
"error": {
"message": "(#100) No matching user found",
"type": "OAuthException",
"code": 100,
"error_subcode": 2018001,
"fbtrace_id": "CTdzskm/2rM"
}
}
Nothing I do seems to change this. I simply cannot get my application to send a message to the Facebook Messenger chat via cURL.
Make sure you are using the same page-scoped access token to send the new message that was used when you received the person's PSID.

Facebook API Webhook - Get Post ID

Can I get a specific post ID from a Webhook, currently I can make an API call and get all the data I need and store it locally to display to the user, however if I decide to use Webhbook to get new updates all they give me is a UID and ID which are both the same.
Is there any way to retrieve the specific post/notification ID through Webhook? Or does it only really tell you that you its time to make another API call and update/compare your records?
Here is an example of what I am returned -
{
"object": "user",
"entry": [
{
"uid": "123456789",
"id": "123456789",
"time": 1374846331,
"changed_fields": [
"feed"
]
}
]
}
Thanks.

Getting the pages that the user is administrator

I'm looking for a way to list all pages where a given user is an administrator. Is this possible? If so, where should I be looking?
Not sure what you are looking to accomplish. If you want to prompt the user to add your app to a page the are an admin of, you can do it through the javascript SDK. (https://developers.facebook.com/docs/reference/dialogs/add_to_page/)
Otherwise, you need to use FQL to query for the information. (https://developers.facebook.com/docs/reference/fql/page_admin/)
You'll need the manage_pages permission from your user in order to gain access to this information.
Using Facebooks FQL and the Graph API you can make a query to the page_admin table using the uid index to reference your user.
https://graph.facebook.com/me/fql?q=SELECT page_id, type from page_admin WHERE uid=me()
An alternative :
The /me/accounts Graph API endpoint
In the Graph API's documentation under the user endpoint there is details about the accounts connection :
The Facebook apps and pages owned by the current user.
You also need the manage_pages permission from your user here.
Here is a sample output from a call to that endpoint :
https://graph.facebook.com/me/accounts?access_token=ABC
...
{
"name": "Unicorn Ville",
"access_token": "XXX",
"category": "Application",
"id": "123"
},
{
"name": "StackOverflow'em Poker",
"access_token": "YYY",
"category": "Application",
"id": "456"
},
{
"name": "The Official Bausley Page",
"access_token": "zzz",
"category": "Non-profit organization",
"id": "789"
},
...
Note that /me/accounts returns "apps and pages owned by the current user"; As such the results you will get will have to be filtered, removing all the application entries or alternatively extracting only the non "application" values of the category parameter.

How to get user's network information using Facebook Graph API? (PHP)

I have been playing with Facebook Graph API around a week, and I still could not find how to get user's network information? I don't know if the Graph API stores user's network; I didn't see such information. Simply, if a user is in "Google" network, may I get the name and the ID of the networks that the user belongs to?
If this is not possible, may I reach the user's secondary email addresses?
Thanks for your help.
Using FQL : the affiliations field of the User table contains this information
Sample call:
https://graph.facebook.com/fql?q=select affiliations from user where uid= 4&access_token=<ACCESS TOKEN>
Sample response:
{
"data": [
{
"affiliations": [
{
"nid": 16777217,
"name": "Harvard",
"type": "college"
},
{
"nid": 50431648,
"name": "Facebook",
"type": "work"
}
]
}
]
}

Categories