Basically, if we want to update an action, it is very easy. However, the question "why do we need to update an action? '. An action generated by the built-in action of the Facebook Open Graph can only be published once. We can not publish the same action for the second time. In fact, sometimes visitors often arrive at the same page for some time. This usually happens on the blog tutorial. Consider the following code to update an action
function setUpdateAction(token){
FB.api('/'+IDAction+'?access_token='+token,'post',function(response){
console.log(response);
});
}
Where, IDAcion is the ID of an action. When viewed from above code, updating the action is very easy. However, the difficulty is how do we know the action ID of an article that has been published to the right? The answer to this question is easy. Let us take an example, suppose you are reading an article from threelas, while the article you've read before. In this situation, you can not publish action read of the article. An error message will be generated from the JSON output action read
User is already associated to the article object on a unique action type Read. Original Action ID: 3475653621349
Through this error message we can update an action read of the article. Here is an example of an easy way to update the action read.
FB.api('/me/news.reads?article='+window.location.href, 'post',function(response){
if (!response || response.error) {
var statusnih = response.error.message;
var getidid = statusnih.split(" ");
var IDAction = getidid[18];
FB.api('/'+IDAction+'?access_token='+token,'post',function(response){
console.log(response);
});
} else {
console.log('Post was successful! Action ID: ' + response.id);
}
});
};
Yes, we split the sentence error into a matrix of 1 x 18 (matrix column). Then we take the matrix components to 18. The matrix component is an ID of action read of a particular article.
Post a Comment