Reputation: 2374
We recently launched an app, where users can invite friends to participate in the contest. Because we're dutiful software engineers, we're wanna delete the app requests right after the user accepts the request.
The code below worked in several projects, but now fails with an error.
code (requestId = simple id without "_userId"):
$this->facebook->api($requestId, "DELETE", array("access_token" => $this->App["fb_app_access_token"]));
error:
{
"error": {
"message": "(#100) Requires valid app request IDs",
"type": "OAuthException",
"code": 100
}
}
we don't attach the user_id to the request_id, because the user hasn't authenticated the app yet, so we simply don't know the id at all.
has someone experienced the mentioned problem or found a solution for this problem yet?
Upvotes: 1
Views: 499
Reputation: 195
Every request ID represents unique request to only one user at a time
To delete the app request you may first query the request_id before making a delete request for it.
you may query the graph api for the request_id whether it really exists and not deleted then you may try a DELETE request on the request_id
https://graph.facebook.com/[REQUEST_ID]?access_token=APP_ACCESS_TOKEN
For more info about requests see Facebook App Requests Overview
Upvotes: 0
Reputation: 96226
You can not delete using just the REQUEST_OBJECT_ID alone, because that request could have been send to multiple users, and this way it would not be clear which one of the instances you want to delete.
You have to use either the combination of REQUEST_OBJECT_ID and USER_ID, or just the REQUEST_OBJECT_ID in combination with a user access token. Since you have none of those when the user has not connected to your app yet, you can not delete the request instance in this case.
You can only wait until they connect to your app, and delete it then.
The docs say,
“As a best practice when the the user lands in your app you should read outstanding app requests via the Graph API.”
– at this point, you could delete all outstanding requests, should they not be needed any more.
Btw., the linked document also says, that requests must be deleted after the user “accepts” them. One could read that to mean that only if the user actually connects to your app, a request can be counted as “accepted”.
Upvotes: 4