接收json数据 回调接口

部分代码

 

<?php
$res = file_get_contents('php://input');    
 
var_dump($res);//返回值

//下面是解析post过来的 json  数据
$data = json_decode($res, true);
//echo $data['name'].' '.$data['score'];
    
    

//下面是保存$res到目录下的newfile.txt文件  确认是否接受到东西
$content = $data['msg'].$data['code'];

$file1 = 'newfile.txt';

$fp = fopen($file1, 'w');

fwrite($fp, $content);

fclose($fp);

//保存文本


echo "ok";

$con=mysqli_connect("localhost","myscvZYEi24","mgkQQt6fC9duHf4f1I7","myscvZYEi24");//创建MySQL连接
// 检测连接
if (mysqli_connect_errno())
{
    echo "连接失败: " . mysqli_connect_error();
        
}


mysqli_query($con,"UPDATE xy_user set user_name = '95559' where USER_id=46");

mysqli_close($con);//关闭链接
?>


版权声明:本文为aaa117659928原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。