Is PUT similar to POST?
I'm getting some inbound requests (apache) with this: [REQUEST_METHOD] => PUT
I've never worked with this request method before. So I have to ask if I'm supposed to process it differently.
The people sending me data are claiming to be sending xml. So my script has this:
<?php
if(isset($HTTP_RAW_POST_DATA)) {
mail("me@myemail.com","some title i want", print_r($HTTP_RAW_POST_DATA, true));
}else{
die("not post data");
}
?>
I'm stuck here now. If there's a PUT request, do I replace $HTTP_RAW_POST_DATA with something else?
According to the php docs, PUT
data can be read using the php://input
stream (which is preferred over $HTTP_RAW_POST_DATA
).
$putdata = fopen("php://input", "r");
$str = stream_get_contents($putdata);
fclose($putdata);
来源:https://stackoverflow.com/questions/11422844/php-accessing-incoming-put-data