Does anybody know the syntax for performing an http get or http post request from the command line? Thanks.
Does anybody know the syntax for performing an http get or http post request from the command line? Thanks.
Which command line? Using what program? With what data?
The general format for a minimal GET request is:Code:GET /path/to/resource HTTP/1.1 Host: www.example.com Connection: close <blank line>
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
I think the OP wants to access information similarly to the way AJAX does from a server... just a guess, though.
- Mike
Just a thoughtCode:telnet yourserver.com 80 GET /
That request lacks the HTTP version and the Host header, which is vital for HTTP/1.1. A correct GET request should look as mine does above (although the Connection header isn't vital).
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
My apologies if I was too vague. I'm using php. I know that php has a function class that does this, but it's not bundled on my server, so I thought I'd use shell scripting on the command line with the exec() function. I need to send name-value pairs to another server using the POST method and with no form. I also need to get name-value pairs back from that server, but I'm assuming this is as simple as "extract($_POST);".Which command line? Using what program? With what data?
You'll need to write a basic HTTP client using fsockopen().
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Wouldn't exec() work fine?
- Mike
Well yes, but fsockopen() would be simpler, and more likely to work.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Bookmarks