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

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

如何在 codeigniter 的 rest api 中訪問(wèn) c??url post 數(shù)據(jù)?

如何在 codeigniter 的 rest api 中訪問(wèn) c??url post 數(shù)據(jù)?

PHP
Smart貓小萌 2023-03-11 16:34:08
我想使用 curl 將來(lái)自 Codeigniter 控制器的數(shù)據(jù)發(fā)布到 API。我無(wú)法訪問(wèn) API 中的帖子數(shù)據(jù)。這是我的 CURL 代碼。...     class SearchJobs extends CI_Controller {public function index(){       $headers = array(        'Content-Type:application/json'    );    $fields=$this->input->post();    /////////////////////get jobs/////////////////    $api_path=API_PATH."index.php/searchJobs/getJobs";    $ch = curl_init();    curl_setopt($ch, CURLOPT_URL, $api_path);    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");    curl_setopt($ch,CURLOPT_POSTFIELDS, json_encode($fields));    $featuredJobs = curl_exec($ch);      if(curl_errno($ch)) {              echo 'Curl error: ' . curl_error($ch);            exit();        } else {              // check the HTTP status code of the request            $resultStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);            if ($resultStatus != 200) {                echo stripslashes($featuredJobs);                die('Request failed: HTTP status code: ' . $resultStatus);            }         $featured_jobs_array=(array)json_decode($featuredJobs);         print_r($featured_jobs_array);         exit();      }     $this->load->view('searchjobs/index',array('featuredJobs'=>$featured_jobs_array));}}...這就是我在 API 中訪問(wèn)它的方式:... public function getJobs_post(){       $data_array=array();    $res_array=array();    $pageNo = $this->input->get('pageNo');    $where = ' j.isActive="y" and isApproved=1  ';    $posted_skills=$this->input->get('skills');    $locations=$this->input->get('location');...但是,我可以使用相同的方法從郵遞員輕松訪問(wèn) API 中的發(fā)布數(shù)據(jù)$this->input->get('skills');。
查看完整描述

1 回答

?
哈士奇WWW

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

刪除 Json 標(biāo)頭 $headers = array( 'Content-Type:application/json' );

并 在沒(méi)有 json_encode 的情況下直接發(fā)布數(shù)據(jù) curl_setopt($ch,CURLOPT_POSTFIELDS, $fields);


查看完整回答
反對(duì) 回復(fù) 2023-03-11
  • 1 回答
  • 0 關(guān)注
  • 127 瀏覽

添加回答

舉報(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)