Facebook Like-button comment box event subscribe - events

Long story short;
I have facebook Like-button on my website with comment box enabled.
I need to refresh current page every time user clicks like button (likes or unlikes my content).
I can achieve this with event.subscribe and edge.create / edge.remove events but the problem is that user should be able to post comments with like-clicks, too.
Currently this works fine with like-clicks only but the edge.create / edge.remove event executes in a few seconds after user has clicked like button and therefor not giving user enough time to write her comment in the comments box and post it.
I've tried comment.create and comment.remove events, but they're not firing at all when the comment is posted and because of that the page just won't refresh at all.
So the problem is;
Does anyone know how I can execute page refresh when user posts comment with like-click via the comment box that is integrated with like-button?
Any help would be appreciated! Thanks!

After struggling with this same problem for a while, and not being able to find a solution, I decided to go another approach.
While I see value in the Comments Box, I also see it as not very good design to have a Comments Box appear seconds before the page redirects/refreshes. So... with a little CSS you can hide the Comments Box, which might be a good option for you until Facebook makes Subscribing to a Like Comment Post, or Close of the Comments Box.
.fb_edge_comment_widget {
display: none !important;
}

Related

Test invisible recaptcha

We have integrated invisible recaptcha in one of our websites. Whenever we submit the form it automatically submits.
I read in some google groups that we would get a challenge when accessed on edge browser. But for us, it is automatically submitted.
Any specific steps to test the invisible recaptcha?
You can test invisible recaptcha by using Chrome emulator.
You will need to add a new custom device (BOT) in developer tools, and set User Agent String to Googlebot/2.1 on Desktop. Then use the new BOT device when testing on your site to trigger the recaptcha authentication.
Note: ReCaptcha v3 will still let the google bot pass as it has a score of 0.9 when emulating in Chrome.
V2 INVISIBLE
In this case just use Incognito or Private browsing to see it works.
Here is the testing link where ReCaptcha is working:
https://www.google.com/recaptcha/api2/demo?invisible=true
Please give the credits to the guys in comments below.
I found an excellent answer that works as of 2018-08-27.
In Chrome, hit F12 to open the Developer Console. Next, toggle the Device Toolbar, select a device and click Edit... Now, add a new device with the following configuration:
Once you hit save and use the new device, the ReCaptcha should open a modal requiring the user to match images.
Credit: This answer was originally posted on https://www.tectite.com/fmhowto/test-invisible-recaptcha.php?WWWTECTITE=p32j2na5otc4rmtbmfsmf9rci6
May 2021
Everyone was talking about using the demo page to test it out. What we get after we tested and how it should looks like is what everyone miss out. Or probably thats why most of us are still searching for the answer.
Even though this question is 3yrs old, still its not clear how this recaptcha works. Iam trying my best to break in steps. Let me know if its works for you.
Google Demo page test
Important
Follow the steps below in the Incognito window
with the parameter
Go to this url https://www.google.com/recaptcha/api2/demo?invisible=true (notice the url has ?invisible=true parameter at the end)
You should see nothing but an pre-filled form with an active 'submit' button with no 'checkbox' captcha, instead you will see the badge at the bottom right.
Click the 'Submit' button and you should see something like this. This is the verification check point.
4. Select the relevant image and the page should redirect with the message saying
Verification Success... Hooray!
But what if you didn't see any image?
If you are not seeing any verification image and the form submits with
Verification Success... Hooray!
then either the form is not working (mostly that's not the case) or you need to clear your browser cache and try again.
without the parameter
Go to this url, https://www.google.com/recaptcha/api2/demo (notice, i have removed the ?invisible=true parameter from the url)
You should see the good 'ol robot checkbox captcha above the 'Submit' button.
3. Also you can notice there won't be captcha badge at the bottom right.
Your Website
Try it in the Incognito window
Just like the demo you should get the same result in your website if you use invisible captcha. (Don't worry about the url parameters)
If your page displayed the captcha badge at the bottom right then after clicking the 'submit' button you should see the popup image window.
If you do not get any popup and the form submits then there's an issue with your captcha or could be browser cache.
Not seeing the checkbox ... ?
Here are some notes from reCaptcha help page - https://support.google.com/recaptcha#6223828
If you're seeing this reCAPTCHA challenge, your browser environment doesn't support the reCAPTCHA checkbox widget.
There are a few steps you can take to improve your experience:
Make sure your browser is fully updated (see minimum browser requirements)
Check that JavaScript is enabled in your browser
Try disabling plugins that might conflict with reCAPTCHA
Please note that some sites may have incorrectly integrated with reCAPTCHA - in this case please contact the site's webmaster.
WordPress Contact Form 7 users
You do not need to add the [recaptcha] tag.
reCAPTCHA v3 doesn’t need a CAPTCHA widget (the “I’m not a robot” checkbox used in reCAPTCHA v2) to work, so [recaptcha] form-tags are no longer necessary. If [recaptcha] form-tags are found in a form template, Contact Form 7 5.1 or higher ignores them and replaces them with an empty string.
https://contactform7.com/recaptcha/
As of 2019-06-21, it appears that it is sufficient with Google Chrome (v74.0.3729.169) to bring up a new incognito window to force the recaptcha to execute. (I had needed this for our own recaptcha testing, so I'm glad I found it.)
I am still struggling a little bit with this but I found that the following things make invisible recaptcha puzzle more likely to appear:
Log into the recaptcha admin and set it to maximum security
Open your site from an incognito tab.
Sometimes leaving the login page open and trying to login after some time has passed seems to trigger the recaptcha puzzle.
I must admit though that these don't work all of the times and there are times that I really struggle to get it to work.
Update: It seems a bit strange but I have found that the invisible ReCaptcha is more likely to appear when I submit a form using the Enter key instead of pressing a button with the mouse.
Invisible recaptcha check fails if you try to access your page via automated tests (in my case chrome browser) since chrome has a feature to recognize if the browsers is controlled by such software... so try to create easy tests in Python or Java(+webdriver), to see if recaptcha is implemented correctly.
If you did not implement the code yourself, the first thing to check is the source code, see if reCaptcha is actually loaded. When using a CMS, I search for this line (or similar):
script type='text/javascript' async defer src='https://www.google.com/recaptcha/api.js?onload=renderInvisibleReCaptcha&render=explicit&hl=de-CH'
If you have the luxury of a VPN, switch to a bad rep IP or country or an IP commonly used for P2P. This works for me most of the time.
Go thru the steps to test the re-captcha with dev tools open. Go to the network tab and find the POST where the form is submitted. Right click that line and copy as cURL.
Paste into the CLI and voila, you get the failure and the output of the cURL is the HTML that the server sent back.
2022 Answer that worked for me!
Please do give this one a go as it's the only one that actually worked for me after hours of testing.
Go to your reCAPTCHA admin account: https://www.google.com/recaptcha/admin/
Go to your site settings
Move the "Security Preference" slider all the way to the right to make reCAPTCHA trigger more often
Open an Incognito window, or even better a secure web browser with a built in encrypted proxy (I think this makes reCAPTCHA more suspicious of your browser) - I used a browser call Epic Browser, which is also Chromium based: https://www.epicbrowser.com/. Note: Just using Incognito on Chrome did not work for me, hence why I went to go use Epic.
Attempt to submit your form - you should hopefully receive the popup check!
As others mentioned you can also test if the browser alone triggers reCAPTCHA check by going to https://www.google.com/recaptcha/api2/demo?invisible=true and submitting the form.
This finally helped me as I was going crazy thinking my reCAPTCHA setup was not working and that I coded something wrong... But no, it was working! Just not very suspicious apparently.
I hope this helps someone as it did me!
The way I tackled it:
Go to your POST to google.com/recaptcha/api/siteverify
Before the response is returned, set the success property in the response to false.
I'm using Guzzle in Laravel (thanks to this example):
$response = $client->post('https://www.google.com/recaptcha/api/siteverify', [
'query' => [
'secret' => env('RECAPTCHA_V3_SECRET_KEY'),
'response' => $value,
'remoteip' => $_SERVER['REMOTE_ADDR'],
]
]);
$body = $response->getBody();
$contents = json_decode($body->getContents());
$contents->success = false;
return $contents;

ASP.Net Razor not generating Scripts section on timeout redirect

I can't figure out why this is happening. Can anyone shed some light on it?
User navigates to my application. (e.g. http://foo.com/bar)
I have the [Authorize] attribute in my "home" controller for my "index" ActionResult method.
The user is automatically redirected to "http://foo.com/bar/account/login".
The Razor section #section Scripts { } renders.
The user logs in, and upon form submit they are redirected back to the index.
User clicks around on various links, all of which have [Authorize] in the controller. All works.
User waits 20+ minutes.
User clicks any link.
The [Authorize] attribute kicks them back to the Account/Login page, but THIS time the #section Scripts never renders.
UPDATE: I solved this work a work around. I'd like to know the correct way to have done this as what I have done I consider more of a hack than a real fix. So I'll leave this question open for a few days and see if anyone can explain. After that I'll close it.
I did not realize this or I would have mentioned I was using it - my problem was coming from jQuery mobile. When you click a link, the URL in the toolbar shows that address, however the content in the window shows the login page. jQuery mobile has pulled the page in while hidden, and then done it's animations to scroll it into view. This seems to be the cause.
I added an event for $(document).bind("pageinit", function () {}); and inside that, I check for a specific element to be on the screen. If I find it, I assume I'm showing the login page, and I call the same script code that was supposed to have been called when the page loaded.
Closing since there were no answers. The work around provided in the edited OP does take care of the problem.

Back button to ajax results, advice request

I am trying solve the back button issue within my app. The scenario is:
I have a home page with a search form which sends and receives data with $.ajax(), then the results loaded through ajax, their links points to a controller that won't be done by GET in ajax so that means that the page will be refreshed (so the home page with the results looks like this: http://url/en/home and a result link may look like this http://url/fetch/data/x123av).
The problem is which is the best way fix that when click back button to return the results from the search box?
I have found some answers in stackoverflow related to my question:
http://code.google.com/p/reallysimplehistory
http://tkyk.github.com/jquery-history-plugin
But from the documentation of those plugins, they all work by checking the hash change which I don't have.
Hope I have explained well enough, and I do have searched stackoverflow and google for a solution but I didn't find one that is close to this or either I've jumped over it...
Please just point me to the right way :D
But from the documentation of those plugins, they all work by checking
the hash change which I don't have.
If you want to handle the back button with AJAX request you will have to redesign your application so that it works with hashes as that's the only way. Changing the fragment portion of an url doesn't trigger a page reload but it is added to the history, so when you press the back button you are able to detect this change without navigating away from the page.
As mentioned by SLaks in the comments section another possibility is to use the HTML5 history API but obviously this assumes that the client browser supports it.

Windows Phone 7 Sign in screen redirect

Apologise if there is answer for this somewhere else, I can't find any.
I imagine this is a common situation. The first time the user runs the application I want them to be presented with the SignIn.xaml, if they don't have any saved details, else I just want to go straight to the MainPage.xaml.
I'd usually do this by sticking a check in the constructor of the MainPage and if they don't have details navigate away. The problem I have is that
NavigationService.Navigate(new Uri("/SignIn.xaml", UriKind.Relative));
is coming up as a null reference. What am I missing? Is there a proper way to do something like this in WP7?
Thanks
Unfortunately the WP7 navigation framework doesn't handle the "do something on first run" situation very nicely at all.
I suspect the problem you're seeing is that you don't have a NavigationService yet... but even if you did, you'd have a problem: the user could still hit the "back" button. You can't even work around that, because the user pressing back should exit the app... but there's no way I'm aware of for doing that without already being at the first page naturally when the user hits the back button.
The only workaround I've found for this is to have the "sign-in" view in the same page as the normal first page, and display one or the other conditionally. Yes, it sucks... but it's the only approach I've found which works. If you find another, I'll be happy to hear about it :)
Peter Torr covers page redirections quite well here. Two methods are offered with relative merits covered. Edit: Note you can redirect to a login page, rather then employing the popup suggestion for login handling.
Redirecting an initial navigation - Peter Torr's Blog
I'd also recommend familiarising with his accompanying post on places here.
Introducing the concept of “Places” - Peter Torr's Blog
This address back stack handling (certification consideration) and addresses scenarios such as login pages.
Rather than have your main page navigate to a sign in page (which will upset you back stack). Either conditionally set the first page or have the login appear as a popup.
Have a look at this question for more on the subject.
I was able to get Peter Torr's UriMapper approach to work with the separate login / welcome page. The main thing was changing the Uri of the UriMapper again after the login and then changing the query string when navigating back to MainPage.xaml after finishing with the login / welcome page. Otherwise when attempting to navigate to MainPage.xaml from the login page, nothing happened.
For more info and a sample project see http://www.geoffhudik.com/tech/2012/2/19/windows-phone-login-navigation.html. I welcome any thoughts and better suggestions.

Is there an extension or a way to write an extension for firefox that allows a developer to refresh a page, but discard POST data?

I'm a developer, and I spend much of my day refreshing the webapps I work on. Occasionally, I'll encounter pages where POST data was submitted, and firefox will prompt me to Resend POST data or to Cancel.
Now, I know that I can just redirect a page to itself to get rid of this warning, but I still want to keep this warning for our users; I just want to be able to skip it while developing. It's also not just on one page, but at many different points throughout the app, so it's not like I can just do if $debug==true then redirect or something like that.
Basically just a minor convenience issue, but when I encounter the message 50-100 times a day, it can get aggravating. What I want to do is essentially have 3 options when refreshing: Resend POST data, cancel, or refresh without resending POST data
The third option would be equivalent to clicking "enter" in the address bar (which is what I end up having to do). The problem with clicking enter is that I often have to "hard refresh" using ctrl+shift+r, but if I do this with POST data I have to click cancel, then click enter on the address bar, then do a hard refresh after that. I would instead like to press ctrl+shift+r, then continue hard refreshing the page without the POST data.
Does anyone know how to do this? Through an extension or otherwise? It's totally a minor issue, but it's something that constantly bothers me and I actually think it would be quite a useful option.
Thanks
Try to look here.
There is a script that could be useful, but i didn't try it.

Resources