[Resolvido] $_post recebe variável nula do c#
Boa tarde, estou enfrentando um problema em meu código, eu tenho um código em c# que fica ouvindo a porta 12934, quando recebe requisição ele envia um post ao meu arquivo php, o problema está que o *$_POST *recebe valor nulo por algum motivo que ainda não descobri.
código no c#:
string URLreceber = "http://localhost/pweb/modulose";
string URLRetornoimg = "http://localhost/pweb/modulos";
string URLRetornocam = "http://localhost/pweb/moduloscaminho";
using (var cliente = new WebClient())
{
NameValueCollection modulose = new NameValueCollection();
modulose["folha"] = folha;
modulose["informe"] = informe;
modulose["cartao"] = cartao;
Console.WriteLine(modulose["folha"]);
Console.ReadKey();
resultimg = cliente.UploadValues(URLRetornoimg, modulose);
retorno = Encoding.UTF8.GetString(resultimg);
Console.WriteLine(retorno);
Console.ReadKey();
}
código em php:
$app->post('/modulos', function (Request $request) use ($app) {
$modFolha = '';
$modInforme = '';
$modCartao = '';
if(isset($_POST['folha'])){
$modFolha = $_POST['folha'];
}
if(isset($_POST['informe'])){
$modFolha = $_POST['informe'];
}
if(isset($_POST['cartao'])){
$modFolha = $_POST['cartao'];
}
if($modFolha == 'sim'){
$modFolha = 'sim';
}else{
$modFolha = 'nao';
}
if($modInforme == 'sim'){
$modInforme = 'sim';
}else{
$modInforme = 'nao';
}
if($modCartao == 'sim'){
$modCartao = 'sim';
}else{
$modCartao = 'nao';
}
if($modFolha == 'sim'){
$modulosImagem['folha'] = './images/holerite.png';
}else{
$modulosImagem['folha'] = './images/holeriteDesabilitado.png';
}
if($modInforme == 'sim'){
$modulosImagem['informe'] = './images/informeVerde.png';
}else{
$modulosImagem['informe'] = './images/informeDesabilitado.png';
}
if($modCartao == 'sim'){
$modulosImagem['cartao'] = './images/cartao.png';
}else{
$modulosImagem['cartao'] = './images/cartaoDesabilitado.png';
}
if(file_exists("../app/config/global.php")){
return new Response(json_encode($modulosImagem), 201);
}
else{
return new Response("Arquivo global não existe", 500);
}
});
Código em .js
// post para a rota que retorna os dados
$http.post('./modulos', data, setting)
.success(function (data, status, headers, setting){
$scope.folha = angular.fromJson(data).folha;
$scope.informe = angular.fromJson(data).informe;
$scope.cartao = angular.fromJson(data).cartao;
})
.error(function (data, status, header, setting){
$scope.ResponseDetails = "Erro: " + data ;
});
var setting = {
headers : {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
}
}
com as linhas:
ini_set('display_errors', true);
error_reporting(E_ALL);
ele retorna:
[http://prntscr.com/lhhpdu](http://prntscr.com/lhhpdu)
e sem as linhas ele retorna NULL, alguém sabe dizer no que estou errando?
retorno no c#:
[http://prntscr.com/lhhqba](http://prntscr.com/lhhqba)
variáveis pegas:
[http://prntscr.com/lhhqr6](http://prntscr.com/lhhqr6)Discussão (8)
Carregando comentários...