-
-
Save minhphuc429/d2b7e4ca8c8c88054e1919e06b1a03a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Check Liked Function - jack098.blogspot.com | |
*/ | |
var checkLike = checkLiked(token, ID_USER, ID_PAGE, ID_POST); | |
checkLike.then(function(data){ | |
console.log((jQuery.isEmptyObject(data["data"])) ? false : true); | |
}) | |
function checkLiked(access_token, uid, page_id, post_id) { | |
// Check Liked | |
return fetch("//graph.facebook.com/fql?q=SELECT+user_id+FROM+like+WHERE+post_id=%22"+page_id+"_"+post_id+"%22+and+user_id="+uid+"&access_token="+access_token).then(function(res){ | |
console.log(res); | |
try{ | |
if (res.status == 400) throw "Bad Request"; // bắt lỗi - xem Api có chả về Http Code là 400 hay không? | |
if (res.status == 200) | |
return res.json() // nếu thành công thì chả về dạng JSON | |
else throw "Fail" // không phải thì cũng False luôn | |
}catch(error){ | |
console.log(error); // In ra lỗi | |
return false | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment