Process HTTP post sent by server - http-post

I would like to ask if anyone can give me some tips on if this is possible:
I'm using a POST to send some data to a server. (for the record, if I use a GET the server internally converts into POST).
The server is posting a reply in the browser via a POST method as well, but it is posting the data to the same page I have been redirected to after the POST - on the server-side, that is.
I would like to know where in my code or how, after I send the POST I can process or ask about that data received, if that is possible that is.
Just to summarize and make this simple, let's say I have a program that asks the server "hey what time is it in Australia". The server takes those parameters and posts the time and, let's say, the weather in Australia ON THE SAME SERVER. I would like to grab those data or be able to say something like "if temperature < 0 bla bla".
Is there a way a can accomplish this? I have been looking around everywhere, but cannot find what I'm looking for. I should say I have no access at all to the code in the server. I cannot believe this is not doable since the data is posted on my browser via a POST. I don't want to change anything on the server side, I just want to grab and process that response via POST from the server.
Many thanks in advance.

Related

ServiceError with basic Direct Line interaction

I've got a basic bot that I am trying to interact with via Direct Line. Following this example, these are what my requests look like:
Start Conversation
Send Activity
The error it responds with is difficult to investigate with such minimal information. The bot itself is working perfectly on other channels.
Has anyone seen this before?
Apologies for answering my own question. It turns out, the Send Activity request was sent as application/text instead of application/json.
I wish the error was more clear on why it was rejecting it but that fixed my issue.

What on earth is this serial-number google is sending me?

I am using the google checkout api to process orders in an online store that i am building.
i ran into an issue today that i cannot move past! oi i am getting such a huge headache from this! So here is the problem:
when i send google an xml-based order, they send me back a grip of information that looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<checkout-redirect xmlns="http://checkout.google.com/schema/2"
serial-number="981283ea-c324-44bb-a10c-fc3b2eba5707">
<redirect-url>
https://checkout.google.com/view/buy?o=shoppingcart&shoppingcart=8572098456
</redirect-url>
</checkout-redirect>
I have been able to use this in the past, and i have just passed in <merchant-private-data> tags in my order request to specify unique orders. i just use the redirect-url above to send them to a page where they complete their order, and google sends me a notification with a serial-number. I pass back the serial-number along with my merchant_id and merchant_key and they send me back a bunch of xml with my order data.
I have already gotten my application working like this. the problem is that now i am trying to make my application so that you can plug in your google merchant id and key and my application will handle the order processing for you. the problem here is that when they send me the serial number in the notification, I don't know which merchant-key or merchant-id to send back to them. And now we have come full-circle to the basis of my question, which is this:
what is this serial-number that google is sending me??? it is definitely not the serial number that the notification api is sending me (unless i have to decode somehow?). Google gives no explanation in their documentation about this and all of the other questions regarding it can be answered by simply using merchant-private-data tags.
Please somebody! some wizard out there! Please help me!!!
The serial number is only relevant to a specific merchant - based on your post, you can equate this to a "specific callback api url" (in serial number notification).
If/when you ask a merchant to give you their mid/key, you'll have to provide them (merchant) the (unique) url they have to provide to Google.
So the "relationship" will be "mid/key/callback api url".
Hth.

Sending and SMS from your computer

There is a ton of data on this subject where you simply take the phone-number+#mobile-carrier.com and send a message, that is not what I am looking to do.
I want to send an SMS, from the command line, in this case, using php, but I would be happy to use bash, and will probably make it into an app or plug in for Safari eventually. Right now, a test case would suit me fine.
I would like to do something like this:
./sms 619-555-1212 "this is the message"
I don't need to receive the message back to the computer, this is a sending only agent.
The criteria that makes all the data I find on this not work, is that I want my correct from: number to show up. I have tried using the email gateway method and changing he from: headers, but it appears they are stripped at the gateway.
I don't mind paying a service to give me certain amount of SMS credits to make this happen. I want to avoid any hardware, where I would have to get a modem or otherwise to connect to my computer.
If I do use a service, something with an example of how to do so within their API would greatly appreciated. I feel this should take me no more than 15 minutes, but I am hours into research and not getting very far with all the little scripts out there that do nothing close to what I want to do.
Thank you very much and sorry that I don't understand this protocol to the best of my ability.
You can send with Twilio using cURL very easily since sending SMS is a simple POST request with three parameters. Here's an example of a bash script that makes calls but could be modified to use the SMS API instead. http://labs.twilio.com/bash/
(I work at Twilio)
you will need sms gateway like http://www.clickatell.com/ for that
You can use any gateway that charges you a few cents for every message sent. They have a simple REST API which requires a very little coding. They even provide you a sample example to get started.

ASP.NET MVC: Send email using SendAsync (System.Net.Mail)

is there any way in MVC to get the System.Net.Mail SendAsync to work, instead of the blocking Send method?
I tried using it but hit the "Page starting an asynchronous operation has to have the Async attribute" error, which I obviously can't resolve (or can I?) because there is no ASPX page with an #Page directive where I could add the Async attribute.
Help is greatly appreciated :(
If you're using a third party service such as gmail to send your email and relying on SendEmail or SendAsync you may want to set up your own SMTP server which will then relay onto gmail. The benefit is that SendEmail will return much faster and you may be able to forget the whole async thing.
That way if gmail rejects you for whatever reason the email will still sit in your local queue.
This is a quick and dirty way to get somewhat reliable email sending setup.
Instructions (not personally tested, but i did this years ago*) or see this for Windows 7
*of course I only remembered i did this after spending a long time converting over to async :-(
It looks like you want Asynchronous support for ASP.NET MVC. See also "Extend ASP.NET MVC for Asynchronous Action".
This SO question is also relevant.
You may want to consider putting the email into a database table and then have a daemon that sends out emails by processing the queue.
a) if youre not sending billions of emails you can have a log of what you sent
b) you can resend if something fails.
depends how important these emails are, but if theyre important from a business standpoint and mustnt get lost then you should use this approach.

How does incoming mail notification on Gmail works?

I'm wondering how it's implemented in Gmail, that every time you receive e-mail, the list of mails is automatically refreshed. It looks like the server is sending some kind of event to the browser, but how is it possible? Or maybe it’s simle: the browser ask the server for new messages every let’s say 2 seconds? But it would probably kill the performance…
Anyone have some ideas?
EDIT: OK, so if it's the simple answer, how do they manage performance? When I send an email from an other account to the gmail account the view is "refreshed" almost instantly. You were saying about a simple function that returns true / false, but it must have some logic (db connection or reads some files). How they manage it?
See also: How is GMail Chat able to make AJAX requests without client interaction?
Dont know exactly which technoloy Gmail uses, but the concept is to open a channel - using reverse AJAX, comet or sprocket based techniques.
Think of it as the client requesting the server for data, but the server does not return for one minute unless it has new mail. Using this technique, the client can almost show the results in a real time manner and it does not have to poll every 2 secs. Makes sense?
gmail is, in fact, polling the server for updates. Not as often as every two seconds, though. That would be madness. A bit of testing with Tamper Data makes it look like maybe every 20 seconds, though there seem to be multiple events going through that confuse it a bit.
Regarding your edit, I imagine they might have a last-activity timestamp on the account tracking in their database, with the client polling query retrieving that via Ajax and comparing with its last sync to determine whether it needs to do a full update.
You have right with simple answer. Google Mail checking new messages on server via AJAX.
It must be some kind of ajax listener that get informations every X seconds.
I already set something like that for one of my projects. What I was doing is calling a function that was returning true or false. True if the page needed to be refreshed, false otherwise. Then if you have an update, you do another call to get the actual update. This way you don't have to refresh everything every time... but it's still intense on the server if you have a lot of users.
In other words and like chaos said, it's polling the server.

Resources