dongshi9489 2012-05-05 13:58
浏览 47
已采纳

从经过身份验证的用户获取Open Graph操作ID

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!

  • 写回答

1条回答 默认 最新

  • dqsvnsad79721 2012-05-09 12:07
    关注

    This data is not available via FQL, it is currently only available via the Graph API. Hope it will present soon.

    See this questions:

    1. FQL to get user's open graph video.watches activity

    2. How to get all the Open Graph Beta actions generated by an app?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改