本文介绍了使用OpenGraph删除预先发布的文章,或检查是否已阅读所述文章的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为阅读文章创建了一个简单的应用程序,使用以下代码创建帖子:

I've created a simple app for reading articles, which creates posts with the following code:

  FB.api('/me/[NAMESPACE]:read&article=http://example.com/article.html','post', function(response) {

                 if (!response) { 
                      alert('Error Occurred I got no response with ' + $pageURL);
                 }
                 else if (response.error) {
                      alert('Error Occurred' + response.responseText + " " + response.error.responseText);
                 } else {
                     alert('Post was successful! Action ID: ' + response.id);
                     var idToDeleteLater = response.id;
                 }
         });

我希望能够检查之前是否访问过该页面,所以我会成为能够禁止为同一篇文章进一步创建帖子。

And I want to be able to check if the page had been visited before, so I'll be able to forbid any further creating of posts for the same article.

但为了做到这一点,我需要获得文章ID,而我还没有能够使用response.id命令获取它,因为那个只给我个人帖子的ID。

But in order to do that I'd need to get the article ID, and I haven't been able to get to it with the response.id command, since that one only gives me the ID of the individual post.

我不想使用给定的方法:

I don't want to use the given method:

  function postUnreadSpecific()
  {
  var postId = idToDeleteLater;

  FB.api(postId, 'delete', function(response) {
  if (!response || response.error) {
    alert('Error occured');
  } else {
    alert('Post was deleted');
  }
});

因为阅读是通过按钮完成的(与烹饪教程中的相同),所以每当我按下按钮创建新帖子,使用不同的ID,我显然不想手动输入。

Because the reading is done via a Button (same as in the tutorial with the cooking), so whenever I push the button new posts are created, with different ID's and I obviously don't wan't to type them manually.

所以,底线,如何获得页面ID(不是带有response.id的帖子ID),并进行检查,如果之前访问过该页面,则禁用新帖子的创建...

So, bottomline, how does one get the page ID (not the post ID with response.id), and make a check, if the page had been visited before, disable creation of new posts...

推荐答案

Facebook Open Graph操作可以选择独特的。此设置位于高级设置链接下隐藏的配置故事附件下的操作创建页面上。在那里,你会发现一个叫做唯一动作的切换,可以设置为仅允许一次。这样可确保每个用户只有一个action-object对。

Facebook Open Graph actions have the option of being unique. This setting is on the action creation page under "Configure Story Attachment" hidden under the "Advanced Settings" link. In there you will find a toggle called "Unique Action" which can be set to "Allow only once." This ensures that there will only be one "action-object" pair per user.

请注意,在设置操作时需要执行此操作,因为操作不能在获得批准后进行编辑。

Note that you need to do this when you set up the action, as actions cannot be edited after they are approved.

这篇关于使用OpenGraph删除预先发布的文章,或检查是否已阅读所述文章的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 05:14