Created
April 11, 2017 22:44
-
-
Save leandroudala/62cc22db1ba6cf2921fb4332343c18bb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="pt-BR"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Publish Like</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script> | |
<script src="https://connect.facebook.net/pt_BR/sdk.js#xfbml=1&version=v2.8&appId=1853222151575314"></script> | |
</head> | |
<body> | |
<style> | |
fieldset > .output { | |
min-height: 150px; | |
border: 1px solid #ccc; | |
} | |
</style> | |
Login status: <span id="status"></span> <!-- status received by FB.getLoginStatus(...); --> | |
<fieldset> | |
<legend>using access token</legend> | |
<button onclick="postLike(accessToken,0)">Like-us on Facebook</button><br> | |
Output<br> | |
<div class="output" id="_accessToken"></div> | |
</fieldset> | |
<fieldset> | |
<legend>using page access token</legend> | |
<button onclick="postLike(pageAccessToken,1)">Like-us on Facebook</button><br> | |
Output<br> | |
<div class="output" id="_pageAccessToken"></div> | |
</fieldset> | |
<script type="text/javascript"> | |
// access token was generated by Graph API Explorer at | |
// https://developers.facebook.com/tools/explorer/ | |
// App: MASP WIFI | |
// user access token : leandroudala | |
var accessToken = 'EAAaVfugI1xIBAHdiCKFtSoSFpNwZCWUfLcHimbhdsfAUrhQhmUz4ug26g0s0rTAVYaJcdnO0LSNaM6TZC2PEgJeF6rixDx0t81aHUUjFHE8eMSEfEVSc2TfFMO1gnH8EpFjf2PQ5c1nJxZAIyt5GkPjBwbc32QZD'; | |
// page acess token: maspmuseu | |
var pageAccessToken = 'EAAaVfugI1xIBAOepex5ZAMbBnofLxt1nkGPZCKa2WnNy2qV8n9HZA7csEFNBWoOMuTK436rXL4GZBRWkAyRwTK5q1x6L37x9y7JWx3Fc4R3lIN5SDdsFUsr3ZAuGWudjGwKBb9PHhHd8Wt49QQcGVRBg9tjfiZCR4ZD'; | |
function postLike(accessToken,p){ | |
FB.api('/191645481024/likes', 'post', {access_token: accessToken }, function(d){ | |
if(p == 0){ | |
console.log('accessToken output'); | |
$("#_accessToken").html(JSON.stringify(d)); | |
} else { | |
console.log('pageAccessToken output'); | |
$("#_pageAccessToken").html(JSON.stringify(d)); | |
} | |
console.log(d); | |
}); | |
} | |
window.fbAsyncInit = function() { | |
FB.AppEvents.logPageView(); | |
FB.getLoginStatus(function(response) { | |
$("#status").html(response.status); | |
}); | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment