我试图向以下PlayFab API提交一个php响应:https://learn.microsoft.com/en-us/rest/api/playfab/admin/account-management/reset-password?view=playfab-rest
这是我的第一个php脚本,我已经使用这个脚本很长一段时间了,并且能够运行我的脚本而没有错误,但是我似乎没有负载。
代码中的回声:
回应了“resp:”.$resp;
来自上述回波的...response是:
的resp:字符串(0) "“
不幸的是,我真的不知道哪里出了问题,也不知道如何修复它,因为没有错误消息。我尝试回显$options数组以控制是否存在有效负载,但没有成功。我意识到我需要帮助,我会非常感激的。
$url = "https://titleId.playfabapi.com/Admin/ResetPassword/json/";
$data = array('Password' => $pw1, 'Token' => $params['token']);
$options = array(
'http' => array(
'method' => 'POST',
'content' => http_build_query($data),
'header' => 'X-SecretKey: xxxxxxxxxxxx\r\n',
'ignore_errors' => true
)
);
$context = stream_context_create($options);
$resp = file_get_contents($url, false, $context);
echo ' The resp: ' .$resp;
var_dump($resp);发布于 2022-03-12 17:44:21
好的,这是解决办法。我能够让它在邮递员中工作,当我测试代码时,它就能工作了。
下面是起作用的片段:
echo '>>>>>>>>>> TEST <<<<<<<<<<';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://99999.playfabapi.com/Admin/ResetPassword?Password=pekapeka&Token=1B5A9C01EFD5DB69',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => array(
'X-SecretKey: xxxxxxx',
'Content-Type: application/json\\'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
print_r($response);
echo '<br>========== END ==========';https://stackoverflow.com/questions/71343622
复制相似问题