i need to call a HTTP request in ubuntu how do i do it? I can't seem to find an answer around on how to to do it?
How do run the following url without calling a browser like lynx to do it?
http://www.smsggglobal.com/http-api.php?action=sendsms&user=asda&password=123123&&from=123123&to=1232&text=adsdad
in your command prompt, run the following:
curl http://www.smsggglobal.com/http-api.php?action=sendsms&user=asda&password=123123&&from=123123&to=1232&text=adsdad
the curl command executes an http request for a given url and parameters.
if you need to specify another HTTP method, use curl -X <TYPE> <URL>, like this:
curl -X POST http://www.smsggglobal.com/http-api.php?action=sendsms&user=asda&password=123123&&from=123123&to=1232&text=adsdad
curl documentation: http://curl.haxx.se/docs/manpage.html
to display the results:
curl http://www.smsggglobal.com/http-api.php?action=sendsms&user=asda&password=123123&&from=123123&to=1232&text=adsdad
or
to save the results as a file
wget http://www.smsggglobal.com/http-api.php?action=sendsms&user=asda&password=123123&&from=123123&to=1232&text=adsdad
Related
I am trying to copy the following curl command using meteor HTTP
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}' http://localhost:8545
The command is from here
This is what I tried:
HTTP.call('POST',"http://localhost:8545",{data:{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}},function(res,error){console.log(res)})
but it returns null. The curl command gives {"jsonrpc":"2.0","id":83,"result":"(the blocknumber)"}
You have to swap error and res params.
HTTP.call('POST',"http://localhost:8545",{data:{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}},function(error, res){console.log(res)})
I'm working on OAUTH 2.0 stuff using following curl command which is working fine in my terminal.
command -
curl -u testclient1:testpass1 http://localhost/oauth2-server/token.php -d 'grant_type=password&username=bshaffer&password=brent123'
I want to know what's equivalent HTTP request for above CURL command so that, i can use guzzle(comparatively easier) to make HTTP request to get the token. I've tried a lot of combination but not getting the right way to do it.
finally after a lot of googling I managed to find out the equivalent HTTP request of that CURL command.
Here is the command -
http://testclient1:testpass1#localhost/oauth2-server/token.php?grant_type=password&username=bshaffer&password=brent123
In slack you can script slackbot to post messages to a channel like this:
curl --data "$msg" $'https://<yourteam>.slack.com/services/hooks/slackbot?token=<yourtoken>&channel=#random'
Now i'd like to mention a username as the first part of the message like msg="#joernhees hello self".
The problem with this is that if the --data argument of curl starts with an # sign it will interpret the string after the # as filename and post its content. Is there a way to make curl ignore the # sign and to send a literal # as the first char of a post request?
If you are on a new version of cURL you can also use the --data-raw option:
http://curl.haxx.se/docs/manpage.html#--data-raw
A word of warning is that looking my laptop it appears Yosemite ships with an older version of cURL.
In general if you're creating tools to post to Slack I'd recommend using an HTTP library in your script rather than calling out to a shell and invoking the curl command.
Actually i just found out i can do this (not sure it's the best option though):
curl --data '#-' $'https://<yourteam>.slack.com/services/hooks/slackbot?token=<yourtoken>&channel=#random' <<< "$msg"
The trick is to tell curl to read from stdin #- and then pass the message in via that.
I am sending a curl request pointing to an url containing unsafe characters in it like /test/#/test1.html
I tried below possible ways but was not working. The Url ends when it sees a # in it and the remaining part is not processed. I took a packet capture and found that the url which is sent by curl is just http://<someIP>testsite/ and not http://<someIP>testsite/#/file.html
curl -v -X 'GET' "http://<someIP>/testsite/#/file.html" -D header.txt -o body.txt
curl -v -X 'GET' 'http://<someIP>/testsite/#/file.html' -D header.txt -o body.txt
Could somebody help in answering how to escape the # or how to make curl to send this complete URL ?
What's after # is never sent to the server in the HTTP request. That can only be read through some client side code (js for example). There is no way of making Curl send that.
I am not sure if this helps, but you can try to encode # char to a URL "safe version": %23
Here you can find more useful information: http://www.url-encode-decode.com/
I am in my Terminal and I want to send a POST request to a given URL. I have tested this with a REST client so I know that the parameters work.
So lets say I want to POST the following parameters:
username=tony
password=secret
To my URL: https://exmaple.com/login/
I tried the following curl command in my Terminal (I am using OSX Lion)
curl --data "username=tony&password=secret" http://exmaple.com/login/
I get an 500 Server Error back from the server so I am now thinking of something that could be different between the REST Client and the curl command.
Thanks for your help
Update: I am using a https service. Do I have to adjust my curl command to account for this?
Try this
curl -F username=tony -F password=secret http://exmaple.com/login/
-F (reference) should probably do the same as --data? Possible the problem is in the webapp.
Maybe the app you are hitting uses basic auth for authentication? Try this one:
curl --user name:password http://exmaple.com/login/