Why some programmers use GET instead of POST in request that modify information on server? - http-post

I've learned that you shouldn't be using GET requests for URLs that modify information on the server because you could get problems with browser link prefetch, search engine crawlers etc.
But when I'm viewing the source code for some sites I saw that many big companies doesn't use this approach.
For example: I signed up for tidal.com and activated a subscription.
When I went to the subscript page I got a page where I was able to cancel my subscription. But the button "cancel my subscription" is not a form performing a POST request, but simply a link to https://my.tidal.com/br/account/subscription/cancel
as well reactivate subscription is a link to https://go.tidal.com/br/account/subscription/resume/40cd9e3e-3d58-4c80-aee7-c378011b49d4
Why are they doing that if my action is modifying information on the server?

Related

Prevent Google Web Preview bot

I noticed today in the webserver logs that we sometimes get bursts (450 requests in 2 seconds) of requests from a useragent with Google Web Preview. Looking at other stackoverflow it seems this is probably related to the preview functionality on the search page or maybe to the saved/most used links at the bottom of a users chrome tabs.
I've already blocked these particular URLs in the robots.txt, so, it's obviously ignoring that. It seems from this 2010 instant previews page that you can add a nosnippet tag and Google will then not try to fetch the preview. However, it seems that adding nosnippet wouldn't actually stop the request (as they'd still have to fetch the page to parse out the tag).
Short of blocking Google's ip address which I don't want to do, is there a decent way to stop Google hammering the server periodically.
I think you probably did it, but when I get such issue I make a buffer page, and provide link on that page e.g link for admin panel that I don't want to be rendered and use NO Index on that page

Display text in website using WebSocketServer & Arduino

I'm looking to do the following:
I have a device that receives data from a website, in this case to light up an LED. However, I would like to do the reverse now, where I can click a physical button on the device (to trigger code) and send a message to display on the website. The website itself is just simple HTML, and I'm using the ESP8266 to send the data over wifi, programmed using arduino code and the WebSocketServer library. I'm not quite sure how to get a message across, nor how to actually display it within the website. I apologize if this is quite easy, but I'be been wracking my head for two hours trying to find it online, and have had no luck. Cheers!
In reference to http://www.instructables.com/id/Arduino-Esp8266-Post-Data-to-Website/ blog by Khalilm , It seems to be much easy for accomplishing your aim.He explains it in six steps.
HTTP works as a request-response protocol between a client and server. A web browser may be the client, and an application on a computer that hosts a web site may be the server. Example: A client (browser) submits an HTTP request to the server; then the server returns a response to the client. The response contains status information about the request and may also contain the requested content. On our example the esp8266 is the client and the server that is hosting our website is the server.
Because HTTP is a request-response protocol, as mentioned above, it's not really about "sending" anything to a browser, but rather of making it available to the browser when someone visits the page, the page is reloaded, or the page "reaches out" to the server with a webservice call, for example, to update part of the page.
However, one twist you could do on your project is:
1. Press the button
2. Record the time in millis() for example.
3. Create a small webpage to show "Button was last pressed at ___ millis()"
4. Then press button whenever you like and refresh the page to see updated time.
Beyond that, you'll need scripting on the browser side to poll the webserver. Given that you don't really ever "send" to a website, does this idea make sense, a reasonable derivative of what you were attempting? If so, give it a try and we'll help if you run into problems.

Taking Twilio calls in a new Popup window

I am facing a scenario where live Twilio call gets dropped, if the browser window in which call is received is reloaded. Is there a way to overcome this set-back without affecting the live calls?
Twilio Evangelist here.
Based on your question, I assume you are using the Twilio Client JavaScript SDK? If that is indeed the case, then unfortunately, if the page thats hosting the SDK gets reloaded the connection between the browser and Twilio will drop since the browser is reloading everything, including the JavaScript SDK.
There are a couple of different techniques I can think of off the top of my head that you can use to help avoid page reloads, and another idea that could help you recover a call where the connection to the browser has dropped because of a page reload. A lot of this is going to depend on your specific app and the experience you are trying to create for your users.
So to help avoid having to reload the page:
1) Use AJAX requests to your server in order to avoid page reloads. If your page includes content like a form, or you want to update the page content with data form the server, you can look using AJAX requests to the server instead of a normal full page postback to submit the form, or to retrieve the data form the server. This would help in avoiding having to reload the entire page in those two scenarios.
2) Use an iFrame to host your page content, and then put the Twilio SDK in the parent page (the one that defined the iFrame). This would let you reload the content hosted in the iframe, without having to reload the entire host page, avoiding a reload the the Twilio library. The downside to this is that communicating between content in an iframe and its host can get really messy fast.
Neither of these two techniques is fool-proof. Obviously a user can always just hit the refresh button on their browser, and thats going to cause the connection to drop.
In a case where the page does get reloaded, and the connection from Twilio to the browser gets dropped, one idea is to leverage Twilios capability to help reconnect the caller together. When a user calls your twilio phone number, instead of connecting them directly to the Twilio Client running in the browser (by dialing a client with <Client>), instead dial that caller into a conference <Conference>, and then have the browser client connect into that same conference. The benefit to that is if the browser disconnects, the original caller won't get hung up on, they will still be sitting in the conference room. As long as you've saved the Conference SID or name, you can have the browser client reconnect to that conference.
Hope that helps point you in the right direction.

How to fill out AJAX form programmatically and scrape results?

Basically, I want to use the Facebook Ads Manager Tool to estimate the number of users targeted by a particular set of targeting parameters. I know there is a published API available, but it is only usable if you are on their advertising application "whitelist." I am sure what I am asking is possible. Plus, it would be interesting to learn more about scraping.
Facebook's Ads Manager Tool is basically an AJAX UI for their ads API. In the process of creating a campaign, you can specify targeting parameters, and the page will dynamically report the number of users targeted as you modify the parameters. From what I've read on the web and here on stackOverflow, it is possible to use Firebug or a similar tool to pick apart what requests are being made by the page and to where, then mimicking these calls to get the information you want.
I'm having trouble interpreting the panels of Firebug. I think the URI I'm trying to send a request to is www.facebook.com/ajax/inventory_estimator.php, though I'm not sure how to form a call.
So, if I want to write a script or program that takes a list of words to use as keywords and returns the estimated number of users for each keyword, how could I do it?
Link to Facebook's Ads Manager Tool, Campaign Creation Page:
http://www.facebook.com/ads/create
yes using an extension like firebug to examine the HTTP requests is a good way to do this.
The Net tab is the one you want (last one).
Have you tried irobotsoft webscraper? It has a good ajax support.
Check their forum here: http://irobotsoft.org/bb/YaBB.pl

Does a website link (href) validation service exist?

I am looking for a web service kind of like Google Analytics.
Paste some javascript into your web page and if any of the links there become invalid, hey presto, an email is sent to someone telling them which link, which page etc etc has the incorrect link.
Anyone heard of such a service?
This would slow the page loading down a lot if it had to check for broken links every time someone visited it (basically a http request for every link). Not that it isn't possible, but the implementation would have to be very very good.
Javascript cannot send emails, you would have to use ajax to post the details to another page that would then email the admin. As this is all client side, it is very open to abuse.
I would suggest using a program to do it every now and again. There are even Firefox extensions to do it rather than a program. Google will also list a whole host of websites offering the service.

Resources