ajuda POST em meu site
eai pessoal,preciso enviar
isso:
BODY
{
"esquema": 3,
"atleta": [
37788,
71116,
39152,
50427,
87225,
62009,
81682,
87863,
78435,
68930,
90651,
62136
]
}
em post para essa url /?p=auth/time/salvar&token=<token>
tentei fazer asim mas n deu:
<?php
/////////////////////////LOGIN\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
$email = $_POST['email'];
$senha = $_POST['senha'];
$jsonurl = "[http://cartolaboladao.16mb.com/api/?p=login&login=".$email."&password=".$senha;](http://cartolaboladao.16mb.com/api/?p=login&login=)
//Retorna o conteudo do arquivo em formato de string
$json = file_get_contents($jsonurl,0,null,null);
//Decodificando a string e criando o json
$json_output = json_decode($json);
$token = $json_output->glbId;/////////////////////////////////////////////////////////////////////////
$url = "http://cartolaboladao.16mb.com/api/?p=auth/time/salvar&token=".$token;
$data = '{
"esquema": 3,
"atleta": [
37788,
71116,
39152,
50427,
87225,
62009,
81682,
87863,
78435,
68930,
90651,
62136
]
}';
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
var_dump ($options);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);if ($result === FALSE) { / Handle error / }
var_dump($result);
if(is_callable('curl_init')){
echo "Enabled";
}else
{
echo "Not enabled";
}
?>Discussão (3)
Carregando comentários...