|
@@ -32,14 +32,15 @@ class GameClient {
|
|
|
|
|
|
$options = [
|
|
$options = [
|
|
'http' => [
|
|
'http' => [
|
|
- 'header' => [
|
|
|
|
|
|
+ 'method' => 'POST',
|
|
|
|
+ 'header' => implode("\r\n", [
|
|
'Content-Type: application/x-protobuf',
|
|
'Content-Type: application/x-protobuf',
|
|
'X-Protobuf-Schema: common.proto',
|
|
'X-Protobuf-Schema: common.proto',
|
|
- 'X-Protobuf-Message: common_pack.ReqLogin'
|
|
|
|
- ],
|
|
|
|
- 'method' => 'POST',
|
|
|
|
|
|
+ 'X-Protobuf-Message: common_pack.ReqLogin',
|
|
|
|
+ 'Accept: application/x-protobuf' // 明确要求返回 protobuf 格式
|
|
|
|
+ ]),
|
|
'content' => $binaryData,
|
|
'content' => $binaryData,
|
|
- 'ignore_errors' => true,
|
|
|
|
|
|
+ 'ignore_errors' => false, // 改为 false 以捕获 HTTP 错误
|
|
'timeout' => 10
|
|
'timeout' => 10
|
|
]
|
|
]
|
|
];
|
|
];
|
|
@@ -47,7 +48,14 @@ class GameClient {
|
|
$context = stream_context_create($options);
|
|
$context = stream_context_create($options);
|
|
|
|
|
|
try {
|
|
try {
|
|
- $response = file_get_contents('http://120.76.130.29:8080/RegLogin', false, $context);
|
|
|
|
|
|
+ $url = 'http://120.76.130.29:8080/RegLogin';
|
|
|
|
+
|
|
|
|
+ $response = file_get_contents($url, false, $context);
|
|
|
|
+
|
|
|
|
+ if (strpos($response, '404 page not found') !== false) {
|
|
|
|
+ throw new Exception("API端点不存在(404),请检查URL: " . $url);
|
|
|
|
+ }
|
|
|
|
+
|
|
$userResponse = new ResLogin();
|
|
$userResponse = new ResLogin();
|
|
if ($response !== false) {
|
|
if ($response !== false) {
|
|
|
|
|