Im trying post a request via file_get_contents but i'm getting error 500, i'm doing this:
$params = array("pid" => "000209", "main_widget_pid" => "000209");
$array = array("method" => "bottomline","params" => $params);
$url = 'http://example.com/test';
$data = array('app_key' => '8948a6aa12a1a23Yzglj17QO91Geg', 'methods' => $array);
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded
",
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
var_dump($result);
I believe the problem is in the structure of arrays. But I can not see the problem.
Can anyone give me a way?