简体   繁体   中英

http send get request and catch the response

I am programming some code which send .... I have no idea how to describe this, cause I am not a full time php programmer and the technologies and frameworks are developing very fast.

so, I have a code... well, address:

http://www.something.sk/something/CID=username&VS=012345&RURL=xxx

where xxx is some dress where I can catch response from that server, but it make no sense for me if i will be using, but it should be not blank

file_get_contents(url_above)

so, my questions are:

1) how to do this? 2) Where '?' was lost from that request url, if the api wants http form style get method arguments which looks like /index.php?id=blahblah&VS=012345 but it is it not working this way. 3) when I hard type the url above to the browser url bar, it gives me an error:

Kohana_Request_Exception [ 0 ]: Unable to find a route to match the URI:

which makes no sense. Also, I am not the owner of the server, and the response should be like:

STATUS=ok&CODE=687629

4) so, once again, how to code it properly to send and catch response? Or how to even find on the google, cause I have no idea how to name it. I have seen some posts and php doc, but they are using 'file_get_contents' method as the safest

Please help, thank you very much.

i have'nt fully understood your question,but here's my answer:
Have you stored the values in a database?
if so,use the id of a value in the xxx part of the address.
also, if the user enters an id that does'nt exists,use try/catch (or something else like showing an error.html page) to show the user the appropriate error so they wont get confused.
if you are linking the product in an <a> tag,it should look like this:

<a href:"http://www.something.sk/something/CID=username&VS=012345&RURL='id comes here'">Dress</a>

if this did'nt help you,please feel free to tell me.

Just noticed this, you're sending a page request to the server, not a get request. you can help this by changing your url from:

    http://www.something.sk/something/CID=username&VS=012345&RURL=xxx

to

    http://www.something.sk/something?CID=username&VS=012345&RURL=xxx

then in PhP to get the files (i see you're using Kohana so if you're using 3.3)

    $cid = $this->request->get('cid');
    $vs = $this->request->get('vs');
    $rurl = $this->request->get('rurl');

or if you're not using kohana :

    $cid = $_GET['cid'];
    $vs = $_GET['vs'];
    $rurl = $_GET['rurl'];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM