第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

我收到一個(gè)帶有 json 帖子的身份驗(yàn)證錯(cuò)誤

我收到一個(gè)帶有 json 帖子的身份驗(yàn)證錯(cuò)誤

PHP
飲歌長(zhǎng)嘯 2022-09-12 09:52:03
我正在嘗試進(jìn)行身份驗(yàn)證,我的請(qǐng)求結(jié)果被錯(cuò)誤地返回。請(qǐng)求模型方法: Post, Endpoint: /api/authenticate, 標(biāo)頭變量: [{“密鑰”:“內(nèi)容類型”,“值”:“應(yīng)用程序/json”,“已啟用”:true}], 正文參數(shù): 用戶名: 字符串, 密碼: 字符串, 身份驗(yàn)證類型: 字符串樣品申請(qǐng)POST /api/authenticate Host: mpop-sit.hepsiburada.comContent-Type: application/json{   "username": "xyz_dev",   "password": "XYZ_dev123!",   "authenticationType": "INTEGRATOR"}請(qǐng)求我已發(fā)送$url = 'https://mpop-sit.hepsiburada.com//api/authenticate';$ch = curl_init($url);$header = array(    'Content-Type: application/json',    'Authorization: Bearer '. base64_encode('xyz_dev:XYZ_dev123!:INTEGRATOR'),);curl_setopt($ch, CURLOPT_HTTPHEADER, $header);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);$result = curl_exec($ch);$return=json_decode($result,true);print_r($return);這是返回的查詢和我收到的錯(cuò)誤的結(jié)果。你認(rèn)為我可能在哪里犯了錯(cuò)誤?數(shù)組 ( [時(shí)間戳] => 2020-02-07T09:01:47.426+0000 [狀態(tài)] => 500 [錯(cuò)誤] => 內(nèi)部服務(wù)器錯(cuò)誤 [異常] => io.jsonwebtoken.格式錯(cuò)誤的Jwt異常 [消息] = > JWT 字符串必須正好包含 2 個(gè)句點(diǎn)字符。找到: 0 [路徑] => //api/身份驗(yàn)證 )
查看完整描述

3 回答

?
臨摹微笑

TA貢獻(xiàn)1982條經(jīng)驗(yàn) 獲得超2個(gè)贊

這應(yīng)該工作正常!我收到訪問被拒絕錯(cuò)誤,所以,這意味著代碼工作正常。


注意 您可能需要更改為http_build_query($fields)$fields


$url = "https://mpop-sit.hepsiburada.com/api/authenticate/";

$token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; 

$fields = array(

   "username" => "xyz_dev",

   "password" => "XYZ_dev123!"

);


$header = array(

    'Content-Type: application/json',

    'Authorization' => 'Bearer ' . $token,

);


//open curl connection

$ch = curl_init();


//set the url, fields, vars

curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

curl_setopt($ch,CURLOPT_URL, $url);

curl_setopt($ch,CURLOPT_POST, true);

curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($fields));

curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false); // SSL false if not required

curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false); //False if not required

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);


//execute fields

$result = curl_exec($ch);

//return result echo $result; if you need

echo curl_error($ch);

//close curl connection

curl_close($ch);

請(qǐng)讓我知道它是否有效!


更新 :如果你想使用ssl,它可以讓你免受黑客攻擊。


按照此答案中的步驟激活 ssl : https://stackoverflow.com/a/59919558/12232340


查看完整回答
反對(duì) 回復(fù) 2022-09-12
?
藍(lán)山帝景

TA貢獻(xiàn)1843條經(jīng)驗(yàn) 獲得超7個(gè)贊

2 slashes here, so it does not work:

$url = 'https://mpop-sit.hepsiburada.com//api/authenticate';


查看完整回答
反對(duì) 回復(fù) 2022-09-12
?
catspeake

TA貢獻(xiàn)1111條經(jīng)驗(yàn) 獲得超0個(gè)贊

Do you need the authentication header for this endpoint?


Because what the sample request wants you to send the parameters in the request body like this:


$post = [

   'username' => 'xyz_dev',

   'password' => 'XYZ_dev123!',

   'authenticationType' => 'INTEGRATOR'

];


$url = 'https://mpop-sit.hepsiburada.com//api/authenticate';

$ch = curl_init($url);

$header = array('Content-Type: application/json');

curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

$result = curl_exec($ch);

$return=json_decode($result,true);

print_r($return);

So no need fot the header, it would also be created differently.Authentication: Bearer ...


查看完整回答
反對(duì) 回復(fù) 2022-09-12
  • 3 回答
  • 0 關(guān)注
  • 190 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)