BetaCodeShareBeta

by Code Solutions Project

Simple solutions for common problems

Description: Make POST Request
PHP
JoseluCross
function makePost($url,$keys){

    $options = array(
        'http' => array(
            "header" => "Content-type: application/x-www-form-urlencoded\r\n",
            "method" => 'POST',
            'content'=> http_build_query($keys)
        )
    );
    $context = stream_context_create($options);
    $response = file_get_contents($url,false,$context);

    return $response;
}

Input example

url: URL to which you snd the POST Request
keys: array with keys and values

Output example

POST Response
×Oh snap! Something wrong