BirdEyeというThird_party APIからデータを取得したいとします。私はCURLのCore PHP Inbuilt関数を使用してデータを取得していましたが、うまくいきました。ライブラリに切り替えると、私はそれを返さないので少し混乱します。私はここからダウンロードカールLibrayを持ってCURL - [NULLレスポンス] Codeigniterで
:Curl Library Download and Example
私はちょうど私のライブラリをチェックするためにデモを作成しようとしましたが、正常に動作するかしない、それが働きました。今、私がBird-Eye Apiからデータを取得した場合、わからない。 マイコードはここにある:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
$this->load->library('curl');
// Setting URL To Fetch Data From
$this->curl->create('https://api.birdeye.com/resources/v1/business/147802929307762?api_key=ApiKeyGoesHere');
// To Temporarily Store Data Received From Server
$this->curl->option('buffersize', 10);
// To support Different Browsers
$this->curl->option('useragent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 (.NET CLR 3.5.30729)');
// To Receive Data Returned From Server
$this->curl->option('returntransfer', 1);
// To follow The URL Provided For Website
$this->curl->option('followlocation', 1);
// To Retrieve Server Related Data
$this->curl->option('HEADER', true);
// To Set Time For Process Timeout
$this->curl->option('connecttimeout', 600);
// To Execute 'option' Array Into cURL Library & Store Returned Data Into $data
$data = $this->curl->execute();
// To Display Returned Data
echo '<pre>';
print_r($data);
$this->load->view('welcome_message');
}
}
私はAPIに必要なすべてのパラメータを渡しています間違ったつもりですどこか分かりません。 APIドキュメントを のリンクは次のとおりです。Link to BirdEye Api Documentation
ありがとうございました!私はヘッダー部分が欠けていた。 –
@JayminsFakeAccount:うれしい! –