Hello,
I have some problems with my php script.
I’d like to send a php post request to an external url (server 1 -> server 2 protocol -> server 1 respond)
But i can’t get the post vars on my server 2
Here is my code :
SEND POST :
public static function SendPostRequest_toMediaServer($url = "",$data = array()){
if(!empty($url) AND !empty($data)){
$converted_data = http_build_query($data);
$options = array(
'http' =>
array(
'header' => 'Content-type: application/x-www-form-urlencoded\r\n',
'method' => 'POST',
'content' => $converted_data
)
);
$streamContext = stream_context_create($options);
$result = file_get_contents($url, false, $streamContext);
exit($result
);
if(strpos($result, "true") !== false){
return true;
}else{
return false;
}
}else{
return false;
}
}
RECEIVE POST (debug to test script) :
public function update_avatar(){
var_dump($_POST);
if(isset($_POST['exempleinput'])){
exit("true");
}else{
exit("false");
}
}