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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用php發(fā)送json帖子

使用php發(fā)送json帖子

PHP
猛跑小豬 2019-10-16 11:05:52
我有這個json數(shù)據(jù):{     userID: 'a7664093-502e-4d2b-bf30-25a2b26d6021',    itemKind: 0,    value: 1,    description: 'Saude',    itemID: '03e76d0a-8bab-11e0-8250-000c29b481aa'}并且我需要發(fā)布到json網(wǎng)址中: http:// domain / OnLeagueRest / resources / onleague / Account / CreditAccount使用php我如何發(fā)送此發(fā)布請求?
查看完整描述

3 回答

?
蕭十郎

TA貢獻1815條經(jīng)驗 獲得超13個贊

您可以為此使用CURL,請參見示例代碼:


$url = "your url";    

$content = json_encode("your data to be sent");


$curl = curl_init($url);

curl_setopt($curl, CURLOPT_HEADER, false);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curl, CURLOPT_HTTPHEADER,

        array("Content-type: application/json"));

curl_setopt($curl, CURLOPT_POST, true);

curl_setopt($curl, CURLOPT_POSTFIELDS, $content);


$json_response = curl_exec($curl);


$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);


if ( $status != 201 ) {

    die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));

}



curl_close($curl);


$response = json_decode($json_response, true);


查看完整回答
反對 回復 2019-10-16
  • 3 回答
  • 0 關注
  • 392 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號