NEVER ALONE FR :: Javascript Detect Url Like Facebook
NEVER ALONE FR Index du Forum

Forum du clan never alone
 
NEVER ALONE FR Index du ForumFAQRechercherS’enregistrerConnexion

:: Javascript Detect Url Like Facebook ::

 
Poster un nouveau sujet   Répondre au sujet    NEVER ALONE FR Index du Forum -> Zone public -> Recrutement
Sujet précédent :: Sujet suivant  
Auteur Message
margeorg
Enregistré

Hors ligne

Inscrit le: 16 Avr 2016
Messages: 123
Localisation: Montpellier

MessagePosté le: Mer 10 Jan - 21:35 (2018)    Sujet du message: Javascript Detect Url Like Facebook Répondre en citant




Javascript Detect Url Like Facebook
> DOWNLOAD (Mirror #1)










location.do-nothing() } Of course, the second if is redundant so you can simply do this: if(/^http://cgi.site.com/hp//.test(window.location)) { location.reload() } What you're doing here is testing window.location with a regular expression to see if it matches the URL you want. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count). All rights reserved the content is copyrighted to Srinivas Tamada - Advertise . Consider this the JS only version without too much attention to detail. I simply want to check if a user has liked my page with javascript in an iFrame app. possible with js? or do I need an 'else'? –josh Apr 8 '10 at 0:21 Assuming I understand your logic flow correctly, you only want to perform a reload if the URL matches If that's the case, you don't need an else since you really aren't doing anything. 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. Of course, if you want to do something else then you can use an else if(.) { . in this way you dont need to ask for permissions to know if some one press the like button, but if you whant to know who press it, permissions are needed. If you parse that signedrequest you can get some info about the user including if they've liked the page or not. like page for competition entry. –Adam Pedley Mar 6 '12 at 4:03 4 Adam - your clarification is correct. If you want to refer to the parent's URL, you can use parent.location.href. Categories AngularReact JSjQueryJavaScriptTutorialsWeb Design J2EEHTML5Twitter API(new)MySQLAjaxMost Popular Recent Posts . 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. 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 Sad YOU LIKE ME Smile 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. Join Stack Overflow to learn, share knowledge, and build your career. USERTOKEN . –Chris Jacob Mar 13 '12 at 1:29 3 You are not checking the validity of the signedrequest. Home Srinivas Tamada Entrepreneur, Blogger,Thinker I love the WEB - IndianInvented The WALL SCRIPTLives in Atlanta - United States [emailprotected] more Follow Me on GitHub SrinivasTamada Subscribe my updates via Email Most Popular Posts Login with Facebook and Twitter Ajax Image Upload without Refreshing Page using Jquery. It's back! Take the 2018 Developer Survey today . location.do-nothing() } TIA josh javascript url detection shareimprove this question edited Jul 16 '10 at 17:00 Bill the Lizard 262k150482772 asked Apr 8 '10 at 0:14 josh 2814 add a comment 2 Answers 2 active oldest votes up vote 7 down vote accepted if(/^http://cgi.site.com/hp//.test(window.location)) { location.reload() } if(/^http://co.siteeps.com/hp//.test(window.location)) { location.do-not.reload() resp. Stack Overflow works best with JavaScript enabled .. If you are in an iframe and need to know the parents URL parent.location.href should get you that. shareimprove this answer edited Apr 8 '10 at 0:25 answered Apr 8 '10 at 0:16 Vivin Paliath 67.3k29160251 hi vivin! thx for your instant reply! What should I define instead of 'location.do-not.reload() resp. rev2018.1.10.28327 . Upload and Resize an Image with PHP Login with Google Account OpenID Pagination with jQuery, MySQL and PHP. Auto Load and Refresh Div every 10 Seconds with jQuery. The basic code is rather simple: FB.api("me/likes/SOMEID", function(response) { if ( response.data.length === 1 ) { //there should only be a single value inside "data" console.log('You like it'); } else { console.log("You don't like it"); } }); ALternatively, replace me with the proper UserID of someone else (you might need to alter the permissions below to do this, like friendslikes) As noted, you need more than the basic permission: FB.login(function(response) { //do whatever you need to do after a (un)successfull login }, { scope: 'userlikes' }); shareimprove this answer edited May 23 '17 at 12:26 Communityf 11 answered May 29 '12 at 12:47 DrColossos 10.1k23256 add a comment up vote 3 down vote i use jquery to send the data when the user press the like button. Not the answer you're looking for? Browse other questions tagged javascript url detection or ask your own question. On subsequent visits nothing should pop up though. starts with cgi.site.com/hp –josh Apr 8 '10 at 0:26 show 10 more comments up vote 2 down vote You could use window.location.href to get the URL to do the string comparison. Join Stack Overflow to learn, share knowledge, and build your career. This will pop up a login dialog the first time the user visits the page (which isn't exactly ideal, but works). 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. Facebook allow apps to "Like Gate" access to content. 2008-2018 9lessons.info Made in India. For example - this is ALLOWED: "Like Us to see the competition entry form". like this with JS: if(URL is ' { location.reload() } if(URL is ' { location.do-not.reload() resp. Here's another approach 5a02188284
facebook messenger for s40 javafacebook evite loginaggiungere plugin facebookfacebook like button pt-brpro appio facebookfacebook password of friendsfacebook likes photos downloadcan you get a facebook account deletedapp for facebook nokiamls teams facebook likes


Revenir en haut
Publicité






MessagePosté le: Mer 10 Jan - 21:35 (2018)    Sujet du message: Publicité

PublicitéSupprimer les publicités ?
Revenir en haut
Montrer les messages depuis:   
Poster un nouveau sujet   Répondre au sujet    NEVER ALONE FR Index du Forum -> Zone public -> Recrutement Toutes les heures sont au format GMT + 2 Heures
Page 1 sur 1

 
Sauter vers:  

Index | Panneau d’administration | créer forum | Forum gratuit d’entraide | Annuaire des forums gratuits | Signaler une violation | Conditions générales d'utilisation
Texno x0.3 © theme by Larme D'Ange 2006
Powered by phpBB © 2001, 2005 phpBB Group
Traduction par : phpBB-fr.com