Facebook Api Like Check

Issue #37 new
Miranda Marie
repo owner created an issue

Foo

.

Facebook Api Like Check .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

In a nutshell, if you turn on the OAuth 2.0 for Canvas advanced option, Facebook will send a $REQUEST['signedrequest'] along with every page requested within your tab app. Thats all for this tutorial, you can download the tutorial code and check also the code comments for a better understanding. shareimprove this answer answered Feb 27 '11 at 23:26 Agentx 7927 1 this is the only way if they haven't connected with your application –Kevin Aug 31 '12 at 21:21 add a comment protected by Communityf Mar 4 '12 at 15:32 Thank you for your interest in this question. Nextwe do a request to Facebook that will post the link including the message. Linked 1 How do I create an app in Facebook that will force users to like a page in order to use it? -1 how to check if user like a specific Facebook page or not 0 Check state of a Facebook like button in web page 1 facebook like button - do you know if web user likes your page 0 Check if a user likes my page via website -1 how to hide content until user likes your page without fbml? 0 how to check if you liked fan page with php without app access token 0 javascript detect if the user liked a page -1 How to check a facebook Page is liked by a user? 0 Can I make an app available only to people that like a facebook page? see more linked questions Related 1944How do you check for an empty string in JavaScript?1006Trigger a button click with JavaScript on the Enter key in a text box6261How do I check if an element is hidden in jQuery?2959How do I check if an array includes an object in JavaScript?1649Modify the URL without reloading the page3677How to check whether a checkbox is checked in jQuery?7102How to check whether a string contains a substring in JavaScript?478Updating address bar with new URL without hash or reloading the page1689How to check for “undefined” in JavaScript?1493How does Facebook disable the browser's integrated Developer Tools? Hot Network Questions Minimise the count of prime factors through insertion Why doesn't soda go flat immediately after opening? Adding page specific JavaScript via SXA How to be sure my advisor's insurance recommendations are good for me? Printing without parentheses varying error message using Python 3 Unable to remove a cross-threaded water hose Why is 11 am + 1 hour == 12:00 pm? Compare two numbers given as strings Can working on a mobile app with bad reviews affect my career? Limit of beta-binomial distribution is binomial How to gently turn down a female coworker who asked for a sperm donation? Can you share some screenshots of editor's control panels? What happened to the Rebel soldiers on Hoth? Do I need to coat beef in flour mixture for slow cooked stew? If someone calls something by a wrong name, what are they actually referring to? Who is considered to be the caster of the spell coming from a triggered Spell Glyph? Is there an online resource like Jewish Encyclopedia available that is more up to date? Which popular games have been studied mathematically? How "scrambled" is the data on a RAID5 disk? Why do we only build 7th chords on the supertonic and dominant of a major scale? Can I drive Elon Musk's Tesla in 100 Years? Why bother with even parity? Is there a way to safely have exposed electrical wires? Is it wrong to use a boolean parameter to determine values? more hot questions question feed default . All you can do is trial and error Reply Emily Hi I have exactly same code, but I keep getting error Facebkook (post) request error: Invalid parameter. function parsePageSignedRequest() { if (isset($REQUEST['signedrequest'])) { $encodedsig = null; $payload = null; list($encodedsig, $payload) = explode('.', $REQUEST['signedrequest'], 2); $sig = base64decode(strtr($encodedsig, '-', '+/')); $data = jsondecode(base64decode(strtr($payload, '-', '+/'), true)); return $data; } return false; } if($signedrequest = parsePageSignedRequest()) { if($signedrequest->page->liked) { echo "This content is for Fans only!"; } else { echo "Please click on the Like button to view this tab!"; } } shareimprove this answer edited Apr 17 '15 at 22:33 NHG 3,78152139 answered Feb 24 '11 at 4:16 Jason Siffring 1,27197 12 Warning: Read the Facebook Promotional Guidelines before trying to "abuse" this e.g. Reply MonasteryTech Hi can you tell me how to store the authorization data to MySQL database so that authorization can be done only one time. SupportPlatform StatusDevelopers GroupMarketing PartnersBugs.. I need to write a small web app in PHP which able to read private messages from inbox of the Facebook Page and also reply to the sender. Is this the feature youre looking for? Reply Filipe Barros Hi its not working here :/ when i call the php file wich start the API this error appear Parse error: syntax error, unexpected TSTRING, expecting TCONSTANTENCAPSEDSTRING or ( in /home/pmsmm/publichtml/fb.php on line 5 Reply Olaf Lederer Hi, what is the code on row 5 in your fb.php file? Reply Gnik Nalu Update your PHP version if you see the unexpected TSTRING, expecting TCONSTANTENCAPSEDSTRING error. My helper using PHP SDK: function isFan(){ global $facebook; $request = $facebook->getSignedRequest(); return $request['page']['liked']; } shareimprove this answer edited Jun 4 '11 at 15:50 answered Jun 4 '11 at 15:21 Tom Roggero 3,51411323 add a comment up vote 17 down vote You can do it in JavaScript like so (Building off of dwarfy's response to a similar question): div#containernotlike, div#containerlike { display: none; } window.fbAsyncInit = function() { FB.init({ appId : 'YOURAPPID', // App ID channelUrl : 'http(s)://YOURAPPDOMAIN/channel.html', // Channel File status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); FB.getLoginStatus(function(response) { var pageid = "YOURPAGEID"; if (response && response.authResponse) { var userid = response.authResponse.userID; var fqlquery = "SELECT uid FROM pagefan WHERE pageid = "+pageid+"and uid="+userid; FB.Data.query(fqlquery).wait(function(rows) { if (rows.length == 1 && rows[0].uid == userid) { console.log("LIKE"); $('#containerlike').show(); } else { console.log("NO LIKEY"); $('#containernotlike').show(); } }); } else { FB.login(function(response) { if (response && response.authResponse) { var userid = response.authResponse.userID; var fqlquery = "SELECT uid FROM pagefan WHERE pageid = "+pageid+"and uid="+userid; FB.Data.query(fqlquery).wait(function(rows) { if (rows.length == 1 && rows[0].uid == userid) { console.log("LIKE"); $('#containerlike').show(); } else { console.log("NO LIKEY"); $('#containernotlike').show(); } }); } else { console.log("NO LIKEY"); $('#containernotlike').show(); } }, {scope: 'userlikes'}); } }); }; // Load the SDK Asynchronously (function(d){ var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/enUS/all.js"; d.getElementsByTagName('head')[0].appendChild(js); }(document)); YOU DON'T LIKE ME :( YOU LIKE ME :) Where the channel.html file on your server just contains the line: There is a little code duplication in there, but you get the idea. I simply want to check if a user has liked my page with javascript in an iFrame app. Stack Overflow Questions Developer Jobs Tags Users current community help chat Stack Overflow Meta Stack Overflow your communities Sign up or log in to customize your list. On subsequent visits nothing should pop up though. If you understand how it works, you can use this function (a bit modified) as a social feature forthe comments form on your WordPress website. Makes sense? Reply InReal4D How to allow me to use the application? Reply Olaf Lederer Hi, maybe it will help to read the tutorial again, you need to follow all the steps before you can use the tutorial code. ' '; $msgid = $graphObject->getProperty('id'); } catch ( FacebookRequestException $e ) { // show any error for this facebook request echo 'Facebook (post) request error: '.$e->getMessage(); } This part of the script does the following: If $session exists, the scriptstores the object inside a PHP session variable and a new Facebook session object is created. For example - this is ALLOWED: "Like Us to see the competition entry form". printr( $graphObject2, 1 ) . it just showed Facebkook (post) request error: Invalid parameter I also want to add images with text. I am just trying to post to my own page with php, not from my machine where I am logged in to Facebook. errors are PHP Fatal error: Uncaught exception FacebookFacebookSDKException with message couldnt open file path/to/file.name in D:InetpubwwwrootgandrTXFBAPIfacebook-php-sdk-v4-4.0-devsrcFacebookHttpClientsFacebookCurlHttpClient.php:150 Stack trace: #0 D:InetpubwwwrootgandrTXFBAPIfacebook-php-sdk-v4-4.0-devsrcFacebookFacebookRequest.php(248): FacebookHttpClientsFacebookCurlHttpClient->send( POST, Array) #1 D:InetpubwwwrootgandrTXFBAPIappexample.php(84): FacebookFacebookRequest->execute() #2 {main} thrown in D:InetpubwwwrootgandrTXFBAPIfacebook-php-sdk-v4-4.0-devsrcFacebookHttpClientsFacebookCurlHttpClient.php on line 150 Could do tell me how to post link and images through the app. –Chris Jacob Mar 13 '12 at 1:29 3 You are not checking the validity of the signedrequest. Add this snippetbelow the other PHP code. 28 . it seems i cant get a session :S Reply Olaf Lederer Do you authorized the session using your own Facebook account? The example script is just a demo not an application& if it works on my demo page, the same code should work for you, too. You should check it against your application secret. Home Hello There! Web Development Blog Select Page Home PHP code Facebook API tutorial for PHP Facebook API tutorial for PHP Last updated: 2016-04-10 If you look for alternative way to integrate Facebook into your website,you should try the Facebook API. You can check the other API systems and maybe you get it working with this one? Its a lot of testing because there is not so much real information available. asked 6 years, 10 months ago viewed 148,160 times active 2 years, 8 months ago Blog Take the 2018 Developer Survey Farewell, Winter Bash 2017! Get the weekly newsletter! In it, you'll get: The week's top questions and answers Important community announcements Questions that need answers see an example newsletter By subscribing, you agree to the privacy policy and terms of service. This object is used later if a valid Facebook session is messing. ProductsFacebook LoginSharing on FacebookGamesFacebook App Ads. Consider this the JS only version without too much attention to detail. Reply mncedisi Hi I cant post image into Profile Album but my app is granted for userphoto permission, it gives me this error (220) Application does not have the capability to make this API call. Thanks in advance for your time and attention. Facebook API PHP example Create inside yournew directory a new PHP file and add the following code: PHP validate() ) $session = null; } catch ( Exception $e ) { // catch any exceptions and set the sesson null $session = null; echo 'No session: '.$e->getMessage(); } } elseif ( empty( $session ) ) { // the session is empty, we create a new one try { // the visitor is redirected from the login, let's pickup the session $session = $helper->getSessionFromRedirect(); } catch( FacebookRequestException $e ) { // Facebook has returned an error echo 'Facebook (session) request error: '.$e->getMessage(); } catch( Exception $e ) { // Any other error echo 'Other (session) request error: '.$e->getMessage(); } } 1234567891011121314151617181920212223242526272829303132 / initialize your app using your key and secretFacebookSession::setDefaultApplication($apikey, $apisecret);// create a helper opject which is needed to create a login URL// the $redirectloginurl is the page a visitor will come to after login$helper = new FacebookRedirectLoginHelper( $redirectloginurl);// First check if this is an existing PHP sessionif ( isset( $SESSION ) && isset( $SESSION['fbtoken'] ) ) { // create new session from the existing PHP sesson $session = new FacebookSession( $SESSION['fbtoken'] ); try { // validate the accesstoken to make sure it's still valid if ( !$session->validate() ) $session = null; } catch ( Exception $e ) { // catch any exceptions and set the sesson null $session = null; echo 'No session: '.$e->getMessage(); }}elseif ( empty( $session ) ) { // the session is empty, we create a new one try { // the visitor is redirected from the login, let's pickup the session $session = $helper->getSessionFromRedirect(); } catch( FacebookRequestException $e ) { // Facebook has returned an error echo 'Facebook (session) request error: '.$e->getMessage(); } catch( Exception $e ) { // Any other error echo 'Other (session) request error: '.$e->getMessage(); }} After the application is initiated thehelper object is created. Reply Pete Clark I get the message No session, please login I click on please login but I dont see a screen to login. Any idea why? By the way, what I want to achieve is this. Here's another approach 5a02188284 https://scisaqlenri.podbean.com/e/download-free-facebook-for-blackberry-9630/ http://silverbackhandyman.co.uk/UserProfile/tabid/325/userId/80620/Default.aspx http://brothersofguns.xooit.com/viewtopic.php?p=441 http://dayviews.com/podhode/524166683/ http://e-orion.webrpg.info/viewtopic.php?p=1455 https://prepcomptenre.typeform.com/to/bkhY7Z http://minecraft-galinia.ze-forum.com/viewtopic.php?p=178 http://lolteam.xooit.fr/viewtopic.php?p=266 http://v1-addict.xooit.fr/viewtopic.php?p=239 https://pastebin.com/aQuTGBs2

Comments (0)

  1. Log in to comment