I'm attempting to use Nexmo.com to send and receive text messages. Sending works fine, but I am having some issues receiving messages.
My issue is with the Callback URL and what format that page should be in. Nexmo's documentation is here and says this
Inbound Message
If you have purchased long virtual numbers, you will need to set up a CallBack URL for inbound to which we will send a request for each incoming message. Nexmo will be expecting response 200 OK, or it will retry.
The request parameters sent via a GET (default) to your URL include the following parameters.
Am I missing something extremely simple? Is there somewhere that I haven't found with an example of a Callback URL page? Thanks for any help!
Edit: For clarification, I'm using Nexmo's provided java library, but since their api is all built around URL's the java program simply visits a URL to send the message. Here
are their provided libraries
Not sure if I've understood your question.
Generally, if you want to receive messages, you have to setup a service on your server, with a callback url, say http://api.example.com/sms/
Then you setup this callback url in Nexmo. After that, Nexmo will access your server through the callback url, and send parameters via GET method.
And your server receives those info, and response 200 to Nexmo.
Related
I am reading Detecting Device Type in a web application and just got curious if it would be possible to client to fake the User-Agent when sending the request?
Question(s)
- user sends request via curl command but fakes it to look as if request is coming from Mobile on the server? is it possible?
- Can server detect it?
- Can server prevent it?
Thanks
It is possible and easy. All you have to do is set the user-agent header string. I've seen a browser that allowed you to set it (don't remember which one). On the server it is very hard to know. A lot of bots pretend to be a browser so they don't get filtered out.
I am using java to connect to a website which has a form of type "multipart/form-data". It asks a user, pass, and file to upload.
When i run my java project, the response i get is "200". According to w3.org, anything in the 2xx class of HTTP responses indicates that "the client's request was successfully received, understood, and accepted."
My question is, if this is the response code i get, can i assume that the file was DEFINITELY uploaded to the site, and that there was no error? To put it in other wording, is the code "200" a guarantee that the file i sent is on the server, or is it just indicating that my POST request was understood?
Thank you!
The HTTP status code 200 states that
The request has succeeded.
The server is therefore telling you that the request you made was successful. However, this doesn't tell you anything about what the web application did. It's up to the web application itself to tell you, possibly as part of the HTTP response.
You should check the web application API or specification and interpret the HTTP response accordingly.
I have the following URL
http:actionname.php?user=username&password=pwd&sender=no&audio_file=somefilehere
I want to send an audio file along with the above parameters.
Is it possible to send an audio file as a request parameter?
Thanks in advance...
You can send the name of a file, but not the file itself. URL lengths are limited, practically to about 2000 characters. Theoretically they may be a bit longer, but this is not supported on all browsers. See this answer.
If the file is publicly available, and the file name is a URL itself, the server may fetch the file later.
If you want to send a file, consider having a POST request with the file content in it.
As usually, you will send anything as request to web server, the file content will be transferred as internals of HTTP message (POST parameters as file name, and content separately) outgoing from you to the server, until it finished (it is TCP session and it won't be break up while data is streaming), it could be considered as "request" to web server.
Theoretically, you could send something via URL (HTTP GET request), but you could develop some kind of transport data-over-HTTP-GET protocol to send escaped binary data chunks as GET parameters. It is possible :)
Even sending (uploading) file via POST request also no so plain as submitting form with usual POST parameters, you should use multipart/form-data encoding in the form and special treatment on the server side for that.
It is not good, but not so weird as transmitting data via URL, you could send some data within GET request to the server, look here for more.
Hi i am running a server socket created in java that accepts requests from a client that uses HTTP url to connect and send web requests.
client does this:
URLconnection.opeonConnection(new Url(www.hello.com/hi));
on my server socket it retrieves a Socket object.
is it possible to retrieve the url www.hello.com/hi url that was passed to this socket conection?
Probably, by parsing the client's HTTP headers:
You can get the "/hi" portion with some work. The URL Connection class will use the HTTP protocol to submit some HTTP headers, along with a GET request as "GET /hi HTTP/1.1". The "/hi" portion comes from the URL.
The "www.hello.com" part might be more difficult. The browser will provide the host and port (if port is given) portion of the URL in a "Host: " header. It's likely that your networking infrastructure may contain proxies or load balancers that forward the request on to the final backend server, and if the proxies aren't configured correctly, they won't maintain the original host header. Try it yourself, and talk to your network administrators if it's not working as you expect.
If you want to see what the URL connection class will send to your server you can get an idea by pointing your browser to this URL: http://request.urih.com/. The "request header: raw source" section shows you the HTTP headers sent by an HTTP client (your browser).
The "HTTP Headers for Dummies" web page is also a good introduction to HTTP headers
Yes it is possible to get the String but not the way you likely want it.
You can implement a HTTP-Server (see RFC 2616). But it is likely that you don't want this.
You can also use a Servlet container like Tomcat or Jetty and write a Servlet to use HTTP. With this the Servlet container does all the protocol and you can concentrate on doing the business logic.
As you state you're building a proxy, you're already asking the wrong question.
An HTTP proxy only has to deal with one command: the CONNECT command. You just have to:
Read this one line from the client.
Connect to the target indicated in the command.
Reply with success or failure.
If success, start copying bytes in both directions.
But I don't know why you're even implementing an HTTP proxy when there are dozens of free working ones already in existence.
In in the interface Socket there is getRemoteSocketAddress(). It returns a SocketAddress, and if the implementation of SocketAddress is InetSocketAddress, try to call getHostString().
SocketAddress address =yourSocket.getRemoteSocketAddress().
String address=((InetSocketAddress)address).getHostString();
Hope it helps.
I have the scenario to the HTTP request which is hitted from the browser address bar and i need to redirect to different URL on the client side.
Is there any way to Abort the HTTP request and redirects to the new URL.
No, if you were able to do it, it would be a large vulnerability. The reason being is that the http request would signify request headers being sent back to your browser, indicating that you're already on your way to the other site. If this could be done via javascript, it would definitely be a hack, as it would allow you to redirect a site such as fakebank.com instead of mybank.com.
You cannot do this using just javascript.
You need to capture the request on the server side and make a 3XX request setting the Location http header to the URL you want to redirect your users to