【问题标题】:Mark a notification as read in Facebook graph API在 Facebook 图形 API 中将通知标记为已读
【发布时间】:2014-06-03 19:02:23
【问题描述】:

我愿意使用 facebook graph api 将用户的通知标记为已读,但我现在开始怀疑这是否可能。这是我现在正在尝试的,这是我在 stackoverflow 上的this question 中找到的解决方案。

$http({method: 'POST', url: 'https://graph.facebook.com/' + item.id + '?unread=0'}).
            success(function(data, status, headers, config) {
              // this callback will be called asynchronously
              // when the response is available
              deferred.resolve(status);
            }).
            error(function(data, status, headers, config) {
              // called asynchronously if an error occurs
              // or server returns response with an error status.
            });

当然,item.id 是通知的 id。

我对我的 http 请求使用 angular,但我也不介意其他方法,只是 angular 对我来说是最简单的。我也期待听到有关如何将通知标记为已读的任何想法,我不喜欢任何方式,只是希望它以某种方式发生。

【问题讨论】:

    标签: angularjs facebook-graph-api notifications http-request


    【解决方案1】:

    这是我前一阵子找到的解决方案,忘记发布了。 (请注意,我使用的是 angular.js,如果您不使用 q 或 rsvp 库做出承诺,或者不使用)

    function (notificationId) {
    
        var deferred = $q.defer();
    
        FB.api(
            'https://graph.facebook.com/' + notificationId, 'post', {
            unread: 0
        },
    
        function (response) {
            if (!response || response.error) {
                deferred.reject(response.error);
            } else {
                deferred.resolve(response);
            }
        });
        return deferred.promise;
    }
    

    【讨论】:

      猜你喜欢
      • 2012-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-04
      • 2021-07-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多