文件
mashangyoujiu/_ai_archive/scripts/test_submit_auth.php

67 行
1.9 KiB
PHP

<?php
/**
* 测试 submitAuthentication 接口
*/
// 测试数据
$testData = array(
'name' => '张三',
'id_card' => '110101199001011234',
'phone' => '13800138000',
'id_card_front' => 'http://example.com/id_front.jpg',
'id_card_back' => 'http://example.com/id_back.jpg',
'handheld_photo' => 'http://example.com/handheld.jpg',
'emergency_name' => '李四',
'emergency_phone' => '13800138001',
'emergency_relation' => '父亲'
);
// 接口URL
$url = 'http://localhost/mss.nahaichuan.com/RiderApi/Auth/submitAuthentication';
// 设置请求头
$headers = array(
'Content-Type: application/json',
'Authorization: Bearer test_token' // 这里需要替换为实际的token
);
// 初始化cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($testData));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
// 执行请求
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
// 输出结果
echo "=== submitAuthentication 接口测试 ===\n";
echo "请求URL: " . $url . "\n";
echo "HTTP状态码: " . $httpCode . "\n";
if ($error) {
echo "cURL错误: " . $error . "\n";
} else {
echo "响应内容: " . $response . "\n";
// 解析JSON响应
$result = json_decode($response, true);
if ($result) {
echo "\n=== 解析后的响应 ===\n";
echo "状态码: " . (isset($result['code']) ? $result['code'] : '未知') . "\n";
echo "消息: " . (isset($result['msg']) ? $result['msg'] : '未知') . "\n";
if (isset($result['data'])) {
echo "数据: " . json_encode($result['data'], JSON_UNESCAPED_UNICODE) . "\n";
}
}
}
echo "\n=== 测试完成 ===\n";
?>