I'm trying to post a score on facebook using graph api for a game that i created. My input is the following:
Method is POST:
me/score/score=10
{
"error": {
"message": "(#100) At least one reference object must be specified.",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "Aa4wSne7KqK"
}
}
I was able to do it yesterday, and the score changed to 100. However it is not working today.
If i use the get method to see my score, here is what i get:
{
"data": [
{
"score": 100,
"user": {
"name": "Nassif Bousaba",
"id": "10159173554635214"
}
},
{
"score": 0,
"user": {
"name": "Nassif Bousaba",
"id": "10159173554635214"
}
}
]
}
All permissions were granted since i was able to post the score before.
This worked after changing the code from request ExecuteAndWait to executeAsync. Additionally i had to change the application type to game in facebook application settings. Code is below for android
public void PublishMyScore(String Score)
{
Bundle params = new Bundle();
params.putString("score", Score);
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/"+AccessToken.getCurrentAccessToken().getUserId()+"/scores/",
params,
HttpMethod.POST,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
Log.w("TAG","SCORE ADDED");
Log.w("TAG",response.toString());
}
}
).executeAsync();
}
Related
what is the correct way to get the conversation/messages on a Facebook page?
I am using:
https://graph.facebook.com/v13.0/{page-id}/conversations which returns
{
"data": [
{
"id": "t_XXXX",
"updated_time": "2022-05-25T12:37:30+0000"
}
}
Now trying to get the messages with https://graph.facebook.com/v13.0/{page-id}/conversations/t_XXXX/messages throws
{
"error": {
"message": "Unknown path components: /messages",
"type": "OAuthException",
"code": 2500,
"fbtrace_id": "asdf"
}
}
I'm cross-posting the question from here.
I’m interested in knowing whether it’s possible to fetch all the statuses for all the contexts for a given reference using the GQL API.
The query that I’m currently doing is the following:
{
repository(owner: "owner", name: "name") {
pullRequests(headRefName: "head-ref", last: 1) {
nodes {
id
commits(first: 10) {
nodes {
commit {
oid
status {
contexts {
context
createdAt
id
description
state
}
}
}
}
}
}
}
}
}
This query returns a single status for each status context, and those are the last ones for each:
{
"data": {
"repository": {
"pullRequests": {
"nodes": [
{
"id": "some-id",
"commits": {
"nodes": [
{
"commit": {
"oid": "some-oid",
"status": {
"contexts": [
{
"context": "context-1",
"createdAt": "2021-07-06T21:28:26Z",
"id": "***",
"description": "Your tests passed!",
"state": "SUCCESS"
},
{
"context": "context-2",
"createdAt": "2021-07-06T21:25:26Z",
"id": "***",
"description": "Your tests passed!",
"state": "SUCCESS"
},
]
}
}
}
]
}
}
]
}
}
}
}
On the other hand, if I use the REST API with this query:
curl -i -u se7entyse7en:$(cat token) https://api.github.com/repos/owner/name/commits/some-oid/statuses
where some-oid is the corresponding retrieved with the GQL API, the output contains ALL the statuses. In particular, I can see all the statuses of context-1 and context-2 that happened before those that are returned by the GQL API.
It seems a limitation of the GQL schema given that StatusContext is a node instead of being a list of nodes. Basically, I expect StatusContext to be of type [Status!]! where Status represents a single status for the given context.
Am I missing something? Is this something expected to be changed in the future? Is the REST API the only option?
Thanks.
I opened a support ticket and this is the expected behavior indeed, there are no plans for changing it. The only solution is to use the REST API.
The link to the community forum is this one.
Since yesterday (29/10/2020) i'm having this problem only on one of the pages linked to my app, the others work correctly:
The attached messages that the webhook receives from Facebook do not contain the attachment field.
Only messages with stickers contain the "attachment" field. All others (image, video, audio etc.) No.
What I expect (as facebook documentation) is:
{
"id": "682498302938465",
"time": 1518479195594,
"messaging": [
{
"sender": {
"id": "<PSID>"
},
"recipient": {
"id": "<PAGE_ID>"
},
"timestamp": 1518479195308,
"message": {
"mid": "mid.$cAAJdkrCd2ORnva8ErFhjGm0X_Q_c",
"attachments": [
{
"type": "<image|video|audio|file>",
"payload": {
"url": "<ATTACHMENT_URL>"
}
}
]
}
}
]
}
but I only receive:
{
"object": "page",
"entry": [
{
"id": "119320008135788",
"time": 1604051633128,
"messaging": [
{
"sender": {
"id": "XXXXXX"
},
"recipient": {
"id": "XXXXXX"
},
"timestamp": 1604051632953,
"message": {
"mid": "m_7DRP...."
}
}
]
}
]
}
This only happens on one page from 29/10/2020
Does anyone have the same problem / know why it happens?
The Facebook support team has confirmed my problem, and is investigating.
I am now solving using the graph api to get the desired message information using the mid
GET /v8.0/{message-id} HTTP/1.1
Host: graph.facebook.com
https://developers.facebook.com/docs/graph-api/reference/v8.0/message
Ex.
GET
https://graph.facebook.com/v8.0/' + mid + '?fields=message%2Cfrom%2Csticker%2Ctags%2Cid%2Cattachments.limit(10)%7Bid%2Cimage_data%2Cmime_type%2Cname%2Cfile_url%2Cvideo_data%7D&access_token=XXXXXX
I'm building a chatbot that requires to capture the lat and long when a user sends his location on fb messenger.
I have created and Intent that executes in the "FACEBOOK_LOCATION" event. I found that this intent should give back something like this on the webhook response:
{
"originalDetectIntentRequest": {
"source": "facebook",
"payload": {
"postback": {
"data": {
"lat": 14.556761479425,
"long": 121.05444780425
},
"payload": "FACEBOOK_LOCATION"
},
"sender": {
"id": "1588xxxxxxxxxxxx31"
}
}
}
}
Source
However all i'm getting is this:
"originalDetectIntentRequest":{
"source":"facebook",
"payload":{
"source":"facebook",
"data":{
"postback":{
"payload":"FACEBOOK_LOCATION"
},
"sender":{
"id":"32xxxxxxxxxxxxx73"
}
}
}
Does anyone know if I need to configure a parameter to capture the lat and long, or is this no longer possible in the DialogFlow - FB messenger integration?
Thanks!
I'm trying implement Payments Lite.
Purchase request works without any issues.
Same for purchases list. It returns:
[
{
"purchase_token": "###",
"product_id": "###",
"app_id": "###",
"purchase_time": ###,
"payment_id": "######",
"consumed": false,
"signed_request": "###",
"payment_action_type": "charge"
}
]
But if I try to consume this purchase using purchase_token the request returns:
{
"error": {
"message": "(#100) Tried accessing nonexisting field (consume) on node type (GamesIAPOrder)",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "CPjKLsTkf/G
"
}
}
I'm using this code:
FB.API("/" + purchaseToken + "/consume", HttpMethod.GET, OnConsume, new Dictionary<string, string> {
{"access_token", accessToken}
});
How can I solve it?
The call to consume a purchase_token should be using HttpMethod.POST instead of HttpMethod.GET
https://developers.facebook.com/docs/games_payments/payments_lite#consuming