在将python代码转换为PHP时遇到问题,PHP版本似乎没有发送cookie
Python:
jar = r.cookies.RequestsCookieJar()
jar.set('.ROBLOSECURITY', cookie, domain='.roblox.com', path='/')
resp = r.post(url="https://auth.roblox.com/v2/logout", cookies=jar)
print (resp.content)
我的PHP尝试:
$ch = curl_init("https://auth.roblox.com/v2/logout");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array()));
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_COOKIE, ".ROBLOSECURITY=" . $cookie);
$resp = curl_exec($ch);
print_r ($resp);
PHP输出:
HTTP/1.1 401 Unauthorized
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 83
Content-Type: application/json
Expires: -1
X-Frame-Options: SAMEORIGIN
Roblox-Machine-Id: RP-WEB1004
P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM
PRE"
Date: Sat, 27 Oct 2018 14:29:39 GMT
{"errors":[{"code":0,"message":"Authorization has been denied for this
request."}]}
目前没有回答
相关问题 更多 >
编程相关推荐