Showing posts with label button. Show all posts
Showing posts with label button. Show all posts
Monday, February 27, 2017
Thursday, February 16, 2017
Dynamically add form elements using jQuery such as Input Textbox Radio Buttons Checkboxes Dropdown and Submit Button
Dynamically add form elements using jQuery such as Input Textbox Radio Buttons Checkboxes Dropdown and Submit Button
Available link for download
Saturday, February 11, 2017
Wednesday, February 1, 2017
Facebook Check if user clicked Like page button just liked the Facebook page
Facebook Check if user clicked Like page button just liked the Facebook page
Very often Facebook applications have "Fangate" page, meaning that if user hasnt liked the page and if he opened application - he can see application page with text something like "Please like our Facebook page before using the app" and cant use the application until he is not page fan.
Our clients as usual ask us to track how many users liked the page from the application.
Signed request contains an information about if user like a page:
$facebook = new Facebook(array(
appId => $app_id,
secret => $app_secret,
cookie => true
));
$signed_request = $facebook->getSignedRequest();
$like_status = $signed_request["page"]["liked"];
So, the challenge is to catch the moment when user clicks like button.
The simples way is to store like status to the session. But it doesnt work in Safari, for iframe Facebook applications Safari doesnt accept cookies and user session is lost.
Nowadays most of polar browsers support local storage. So we can use it to store like status information. Example of source code is pretty simple.
This code example should be in template that is rendered if user is a fan of Facebook page:
<script type="text/javascript">
if (localStorage in window && window[localStorage] !== null) {
if (localStorage.getItem(liked_state) == 0) {
// weve go it: user just clicked like button
}
localStorage.setItem(liked_state, 1);
}
</script>
Pretty simple, isnt it?
Available link for download
Friday, January 27, 2017
Subscribe to:
Posts (Atom)