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

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

PHP 中的等效 curl 請求是什么

PHP 中的等效 curl 請求是什么

PHP
慕桂英546537 2021-06-08 15:42:11
我試圖進入 PHP 這個卷曲:curl -X POST -u "apikey:MY_API_KEY" \--header "Content-Type: text/plain;charset=utf-8" \--header "Accept: application/json" \--data-binary "MY_TEXT" \"https://MY_DIRECTION"到目前為止,我想出了這個:$curl = curl_init(); $post_args = array('data-binary' => $MY_TEXT ); $header_args = array(     'Content-Type: text/plain;charset=utf-8',     'Accept: application/json' ); $apiKey = '$MY_API_KEY'; $api_args = array('apikey: ' . $apiKey); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $api_args); curl_setopt($curl, CURLOPT_POSTFIELDS, $post_args); curl_setopt($curl, CURLOPT_HTTPHEADER, $header_args); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curl, CURLOPT_URL, $MY_DIRECTION); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($curl); curl_close($curl); json_decode($result, true);我正在嘗試使用 IBM 的 Personality Insights 服務(wù)。
查看完整描述

1 回答

?
守著一只汪

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

讓我們試試這個——


$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://MY_DIRECTION');

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, "MY_TEXT");

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_USERPWD, 'apikey' . ':' . 'MY_API_KEY');


$headers = array();

$headers[] = 'Content-Type: text/plain;charset=utf-8';

$headers[] = 'Accept: application/json';

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);


$result = curl_exec($ch);

if (curl_errno($ch)) {

    echo 'Error:' . curl_error($ch);

}

curl_close ($ch);


查看完整回答
反對 回復 2021-06-13
  • 1 回答
  • 0 關(guān)注
  • 153 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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