I'm taking a first shot at the Facebook Open Graph API. I've made a custom Action Type and Object Type. For this question I'll name them "myaction" and "myobject".
function postAction(){
FB.api(
'/me/appnamespace:myaction?myobject=http://domain.com/page.php',
'post',
function(response) {
if (!response || response.error) {
alert('Error: ' + response.error.type + ' - ' + response.error.message);
} else {
//alert('Like was successful! Action ID: ' + response.id);
var likedId = response.id;
alert('Action was successful! Action ID: ' + response.id + ' (var = ' + likedId + ')');
}
}
);
}
This works. The action is published to the user's timeline.
But if that user wants to delete that action (or multiple actions) from my site in a different session? Is there a way to query the custom actions from the user and display them? I could work with a database, and store the actionId, but that will conflict when the user has already deleted the action on facebook
The code for deleting the action would be:
function deleteAction(){
FB.api(
'xxxxxxxxxx', // Here the Action ID must be inserted
'delete',
function(response) {
alert('action deleted')
}
);
}
Edit:
This works for getting the action from a specific page (object):
function getAction(){
FB.api(
'/me/appnamespace:myaction?myobject=http://domain.com/page.php',
'get',
function(response) {
if (!response || response.error) {
alert('Error: ' + response.error.type + ' - ' + response.error.message);
console.log(response);
} else {
console.log(response);
}
}
);
}
This works for getting all the custom actions from the user:
function getAllAction(){
FB.api(
'/me/appnamespace:myaction',
'get',
function(response) {
if (!response || response.error) {
alert('Error: ' + response.error.type + ' - ' + response.error.message);
console.log(response);
} else {
console.log(response);
}
}
);
}
In short, is there a way to do this in FQL:
- query the Object ID from the current url?
- query the Action ID from the user (all custom Actions and/or specific action based on the Object ID)?
Thanks in advance!