调用Striga沙箱API创建用户时出现HTTP 404 Not Found错误
Striga沙箱环境用户创建接口POST请求返回404 Not Found问题
今日早间曾咨询过链接相关错误,代码逻辑本身无问题,但当前POST请求出现新错误:向Striga沙箱环境的用户创建接口https://www.sandbox.striga.com/api/v1/user/create发送POST请求时,返回HTTP 404 Not Found错误,响应详情如下:
HTTP/1. 1 404 Not Found Date: Thu, 21 Sep 2023 15:39:13 GMT Content-Type: text/html; charset=utf-8 Connection: close x-xss-protection: 1; mode=block x-content-type-options: nosniff referrer-policy: no-referrer-when-downgrade content-security-policy: default-src 'self' http: https: data: blob: 'unsafe-inline'; frame-ancestors 'self'; permissions-policy: interest-cohort=() strict-transport-security: max-age=15552000; includeSubDomains; preload CF-Cache-Status: DYNAMIC Server: cloudflare CF-RAY: 80a3664c1b5158a8-IAD alt-svc: h3=":443"; ma=86400.
页面下方显示典型的404 Not Found提示。已尝试调整请求头、链接等,但API请求必须使用该链接,代码逻辑看似无误,相关代码如下:
require_once 'vendor/autoload.php'; use GuzzleHttp\Client; use GuzzleHttp\Psr7; use GuzzleHttp\Exception\ClientException; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $client = new Client(['base_uri' => 'https://www.sandbox.striga.com/api/v1/']); $SANDBOX_API_SECRET = '9YiaEuslYPQEjnCM5Ve1NyirgdMovwaaYJekhaWodVAp='; $method = 'POST'; $body = ["mobile" => ["countryCode" => "+34", "number" => "644147933"], "dateOfBirth" => ["year" => 1999, "month" => 10, "day" => 6], "address" => ["addressLine1" => "Calle Bahía de Cádiz 2", "city" => "Sevilla", "postalCode" => "41009", "state" => "Sevilla", "country" => "España"], "firstName" => "Daniel", "lastName" => "González Pitt", "ipAddress" => "79.116.138.131", "email" => "danielgonzalez@gmail.com", "occupation" => "PUBLIC_SECTOR_ADMINISTRATION", "sourceOfFunds" => "FAMILY_SAVINGS", "sourceOfFundsOther" => "Descripción del sourceoffound", "selfPepDeclaration" => true, "purposeOfAccount" => "CARD_INSIDE_EEA", "purposeOfAccountOther" => "Descripción muy corta de purpose", "expectedOutgoingTxVolumeYearly" => "BETWEEN_1000_AND_5000_EUR", "expectedIncomingTxVolumeYearly" => "BETWEEN_1000_AND_5000_EUR", "placeOfBirth" => "ESP"]; $TEST_ENDPOINT = '/user/create'; function calcSig($body) { global $SANDBOX_API_SECRET, $method, $TEST_ENDPOINT; $mstime = floor(microtime(true) * 1000); $hmac = $mstime; $hmac .= $method; $hmac .= $TEST_ENDPOINT; $contentHash = md5(json_encode($body)); $hmac .= $contentHash; $hmac = hash_hmac('sha256', $hmac, $SANDBOX_API_SECRET); $auth = 'HMAC ' . $mstime . ':' . $hmac; return $auth; } $headers = [ 'authorization' => calcSig($body), 'api-key' => 'DhiZ4KSXXF4iJ4vbRieLO7SAHQ63rytSBRISGCwjLuo=', 'Content-Type' => 'application/json', ]; //echo print_r($headers); try { $response = $client->request('POST', '/user/create', [ 'headers' => $headers, 'json' => $body ]); //echo $response->getBody(); } catch (ClientException $e) { // echo Psr7\Message::toString($e->getRequest()); echo Psr7\Message::toString($e->getResponse()); } } else { echo 'Not access'; }
现寻求该404错误的原因及解决办法。
内容的提问来源于stack exchange,提问作者Daniel González Pitt
相关产品推荐
相关产品推荐

