Facebook Graph API V 2.6 User Type - facebook-graph-api

Is there a way to know if the user info being returned by the graph api explorer is a user's profile or a business page?
The query I am using is:
me?fields=feed{from,comments{from}}
which gives me back all the users who have left a comment or a post on my page.
Here is an example of what I would get back for that query:
{
"feed": {
"data": [
{
"from": {
"name": "John's Tires",
"id": "114615108955555"
},
{
"from": {
"name": "John Smith",
"id": "123615108951010"
},
Is there something I can add to the query to make it return a user type? For example- type:user or type:page?
I've searched facebook graph api documentation and found nothing. Thanks in advance for your help.

With metadata=1 you get a type in the response for a single top level item, but I don't know how to do it for a list.
$ fbapi /me?metadata=1 | jq .metadata.type
"user"
$ fbapi /BBCQuestionTime?metadata=1 | jq .metadata.type
"page"

Related

Facebook Graph Api publishing to feed returns: "(#100) Param place must be a valid place tag ID"

I am searching at Facebook Graph Api, using graph api explorer, for some place using the following endpoint:
/search?type=place&q=centauro&fields=id,name,link
I am getting this as response:
"data": [
{
"id": "492103517849553",
"name": "Centauro",
"link": "https://www.facebook.com/Centauro-492103484516223/"
},
{
"id": "313439499156253",
"name": "Centauro",
"link": "https://www.facebook.com/Centauro-313439462489590/"
},
{
"id": "175812113006221",
"name": "Centauro",
"link": "https://www.facebook.com/Centauro-175812079672891/"
},
{
"id": "1423220914594882",
"name": "Centauro",
"link": "https://www.facebook.com/pages/Centauro/1423220891261551"
},...
When I try to publish using the field "id" returned:
/me/feed
with fields:
message: Testing
place: 492103517849553
I get the following reponse:
{
"error": {
"message": "(#100) Param place must be a valid place tag ID",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "DfEKOjZX8g+"
}
}
But if I use de final number of the link:
"link": "https://www.facebook.com/Centauro-492103484516223/"
492103484516223
And try again:
/me/feed
with fields:
message: Testing
place: 492103484516223
It works perfectly.
So, is there a way to get te correct place id for publishing? Or is it a bug?
I was also getting the “(#100) Param place must be a valid place tag ID” error, but got it to go away by providing a JSON string within the 'place' element.
So where the content of your request was this:
place: 492103484516223
Format the place information like this instead:
place: {"id": "492103484516223"}
Currently, this is how you can solve it.
import requests
IG_USER_ID = <YOUR INSTAGRAM USER ID>
USER_ACCESS = <YOUR USER ACCESS TOKEN WITH VALID PERMISSIONS>
CONTAINER1_ID = <ID OF FIRST CONTAINER>
CONTAINER2_ID = <ID OF SECOND CONTAINER>
URL = f"https://graph.facebook.com/v13.0/{IG_USER_ID}/media?caption=Fruit%20candies&media_type=CAROUSEL&children={CONTAINER1_ID}%2C{CONTAINER2_ID}&access_token={USER_ACCESS}"
r = requests.post(URL)

Facebook API process shared object [duplicate]

I just tried through the Graph API Explorer with this path /v2.4/10153513872748291 and I've got this result:
{
"error": {
"message": "(#12) singular links API is deprecated for versions v2.4 and higher",
"type": "OAuthException",
"code": 12
}
}
But https://developers.facebook.com/docs/reference/api/post/ doesn't say anything about deprecation.
I'm not sure if I miss something, or there's another way to get info about an individual post.
Edit: v2.3 works, but v2.4 is the latest one.
Looks like you now need to the combination of the id of the user or page that made the post (or whose wall it is on), an underscore, and then the post id.
For your example post, 10153513872748291, that is made by a page Drama-addict, that has the id 141108613290 – so 141108613290_10153513872748291 will work.
And so does 788239567865981_10153513872748291, because 788239567865981 is the id of the user making the post.
Firstput userId underscore add postId /Likes to check Like status in facebook
userId_post_Id/Likes to fetch Likes Records
userId_post_Id/Comments to fetch Comments Records
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=303261006522998_751199848395776%2FLikes&version=v2.9
**In this link Right side Get Token indide GetAccessToken to select Permission**
303261006522998_751199848395776/Likes
303261006522998_751199848395776/Comments
{
"data": [
{
"id": "124778301449917",
"name": "Manisha Gera"
},
{
"id": "1680577265523548",
"name": "Rubi Sharma"
}
],
"paging": {
"cursors": {
"before": "MTI0Nzc4MzAxNDQ5OTE3",
"after": "MTY4MDU3NzI2NTUyMzU0OAZDZD"
}
}
}

Facebook Objects API Queries o

I have asked some old questions previously but those were quite misleading. So I decided to delete them and creating this one.
My object has a custom property named say it is portal content. In the Facebook Graph API Explorer data related to this object shown like;
{
"created_time": "2015-11-26T08:42:26+0000",
"title": "Title",
"type": "ns:type",
"data": {
"portalcontent": "portalcontent"
},
"id": "12515125125"
},
{
"created_time": "2015-11-26T08:04:09+0000",
"title": "Title2",
"type": "ns:type",
"id": "412512512512"
},
{
"created_time": "2015-11-25T12:56:03+0000",
"title": "Title3",
"type": "ns:type",
"id": "234124124124"
}
I am trying to query this data using Facebook graph api. But can not fetch just based on the portal content custom property.
So far I tried;
appid/objects?pretty=0&type=ns:type&limit=100&portalcontent=portalcontent
to do so. But it is still fetching all objects.
PS: please pm or comment on question for why you are downvoting it. Provide what else you need that I must put on the question. Downvoting for no reason getting people annoyed.
There's currently no way to filter results other than those described on the respective endpoint's docs.
See
https://developers.facebook.com/docs/graph-api/reference/application/objects/
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.5

Graph API Score with GET method can't return score field

I use Facebook SDK 4.2.0 Android to create the leader scoreboard for my game.
I post successfully my score with POST method at /me/scores graphPath:
{Response: responseCode: 200, graphObject: {"success":true}, error: null}
However, when I try to GET the score at /me/scores as well as /793295994100883/scores (793295994100883 is my APP ID), I didn't see my score in JSON result string.
{Response: responseCode: 200, graphObject: {"data":[{"user":{"id":"Facebook USER-ID","name":"Facebook USER-NAME"}}]}, error: null}
In https://developers.facebook.com/tools/explorer, It return my expected string when I get at /793295994100883?field=scores{score}
"scores": {
"data": [
{
"score": 1234,
"user": {
"name": "Facebook USER-NAME",
"id": "Facebook USER-ID"
}
}
]
},
"id": "793295994100883"
Please help with this issue. How can I get score with Facebook SDK?
Thanks!
Which version of the Graph API is your app using? If it's v2.4, you have to specify each field you want to retrieve.
Have a look at my answer here:
Facebook only returning name and id of user

Trello API: getting boards / lists / cards information

Using Trello API:
- I've been able to get all the cards that are assigned to a Trello user
- I've been able to get all the boards that are assigned to an Organization
But I can't get any API call that returns all the lists that are in an Organization or User.
Is there any function that allows that ?
Thanks in advance
For the users who want the easiest way to access the id of a list :
Use the ".json" hack !
add ".json" at the end of your board URL to display the same output of the API query for that board, in your browser ! (no other tool needed, no hassle dealing with authentication).
For instance, if the URL of your board is :
https://trello.com/b/EI6aGV1d/blahblah
point your browser to
https://trello.com/b/EI6aGV1d/blahblah.json
And you will obtain something like
{
"id": "5a69a1935e732f529ef0ad8e",
"name": "blahblah",
"desc": "",
"descData": null,
"closed": false,
[...]
"cards": [
{
"id": "5b2776eba95348dd45f6b745",
"idMemberCreator": "58ef2cd98728a111e6fbd8d3",
"data": {
"list": {
"name": "Bla blah blah blah blah",
"id": "5a69a1b82f62a7af027d0378"
},
"board": {
[...]
Where you can just search for the name of your list to easily find its id next to it.
tip: use a json viewer extension to make your browser display a nice json. Personnally I use https://github.com/tulios/json-viewer/tree/0.18.0 but I guess there are a lot of good alternatives out there.
I don't believe there is a method in the Trello API to do this, so you'll have to get a list of boards for a user or organization:
GET /1/members/[idMember or username]/boards
Which returns (truncated to show just the parts we care about):
[{
"id": "4eea4ffc91e31d1746000046",
"name": "Example Board",
"desc": "This board is used in the API examples",
...
"shortUrl": "https://trello.com/b/OXiBYZoj"
}, {
"id": "4ee7e707e582acdec800051a",
"name": "Public Board",
"desc": "A board that everyone can see",
...
"shortUrl": "https://trello.com/b/IwLRbh3F"
}]
Then get the lists for each board:
GET /1/boards/[board_id]/lists
Which returns (truncated to only show the list id and name:
[{
"id": "4eea4ffc91e31d174600004a",
"name": "To Do Soon",
...
}, {
"id": "4eea4ffc91e31d174600004b",
"name": "Doing",
...
}, {
"id": "4eea4ffc91e31d174600004c",
"name": "Done",
...
}]
And go through this response for each board to build a list of all the lists a user or organization has.
You can do it by calling
GET /1/organizations/[idOrg]/boards?lists=all
It is here: https://developers.trello.com/advanced-reference/organization#get-1-organizations-idorg-or-name-boards
Look at the arguments.
There are several filters and fields. You can customize it.
to get all your boards use
Trello.get("/members/me/boards")
worked for me using client.js
Here is a quick and dirty bash script using curl and jq to get any given Board's ID or List's Id:
key="<your-key>"
token="<your-token>"
trelloUsername="<you-trello-username>"
boardName="<board-name>"
listName="<list-name>"
boardID=$(curl -s --request GET --url "https://api.trello.com/1/members/$trelloUsername/boards?key=$key&token=$token" --header 'Accept: application/json' | jq -r ".[] | select(.name == \"$boardName\").id")
echo "boardID: ${boardID}"
listID=$(curl -s --request GET --url "https://api.trello.com/1/boards/$boardID/lists?key=$key&token=$token" | jq -r ".[] | select(.name == \"$listName\").id")
echo "listID: ${listID}"
Example output:
boardID: 5eab513c719d2d681bafce0e
listID: 5eab519e66dd4272gb720e22