PHP发送GET而不是POST

PHP发送GET而不是POST,php,post,Php,Post,我必须发布一些数据,但相同的地址有一些GET和post函数。我的PHP正在发送GET而不是POST $apiURL = 'https://myAPI.com.br/api'; $data = http_build_query(array('postdata' => 10)); $uriRequest = $apiURL.'/main'; $options = array( "ssl"=>array( "verify_peer"=>false,

我必须发布一些数据,但相同的地址有一些GET和post函数。我的PHP正在发送GET而不是POST

$apiURL = 'https://myAPI.com.br/api';

$data = http_build_query(array('postdata' => 10));
$uriRequest = $apiURL.'/main';

$options = array(       
    "ssl"=>array(
    "verify_peer"=>false,
    "verify_peer_name"=>false,
    ),
    'https' => array(
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'method'  => 'POST',
        'content' => $data
    ),
);
$context  = stream_context_create($options);
$result = file_get_contents($uriRequest, false, $context);
if ($result === FALSE) {
    return var_dump($result);
}
return var_dump($result);
我知道ssl部分不安全,但它只是用于原型设计

我无法让PHP在地址“”上发布INTE而不是get。

从为
https
安全页面创建流上下文的正确方法来看:

<?php
$context_options = array (
        'http' => array (
            'method' => 'POST',
            'header'=> "Content-type: application/x-www-form-urlencoded\r\n"
                . "Content-Length: " . strlen($data) . "\r\n",
            'content' => $data
            )
        );
从为
https
安全页面创建流上下文的正确方法来看:

<?php
$context_options = array (
        'http' => array (
            'method' => 'POST',
            'header'=> "Content-type: application/x-www-form-urlencoded\r\n"
                . "Content-Length: " . strlen($data) . "\r\n",
            'content' => $data
            )
        );

您如何验证这是作为GET发送的?您可以尝试
'http'=>数组吗(…
而不是
https
?从-
https
判断是错误的。@Xatenev,没错!这解决了我的问题。非常感谢!@ThiagoPachioni Cool。我已经提交了关于这个问题的答案。你如何验证这是作为GET发送的?你能尝试
'http'=>数组吗(…
而不是
https
?从-
https
判断是错误的。@Xatenev,就是这样!你是对的。这解决了我的问题。非常感谢!@ThiagoPachioni Cool。我已经提交了关于这个问题的答案。