0
我正嘗試連接到Airbnb並從中返回我的預訂。 我能夠使用cURL成功登錄,但無法檢索預訂。Airbnb API - 未找到操作 - 使用cURL
的保留網址:http://airbnbapi.org/#get-host-messages
正如你所看到的HTTP方法是GET
,client_id
必須在URL和頭X-Airbnb-OAuth-Token
(登錄後)進行傳遞。
執行後,收到以下報頭輸出上登錄的捲曲(通過使用函數CURLINFO_HEADER_OUT
):
POST /v1/authorize HTTP/1.1
Host: api.airbnb.com
Accept: */*
Content-Length: 511
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------aa1ew132ff32wca9
隨着200的HTTP代碼。
登錄後,我進行關於保留翹曲,我得到:
GET /v2/threads?client_id=MyApiKey&_limit=10 HTTP/1.1
Host: api.airbnb.com
Accept: */*
{"error_code":404,"error_type":"invalid_action","error_message":"Action not found."}
用下面的代碼:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.airbnb.com/v2/threads?client_id=MyApiKey&_limit=10');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Airbnb-OAuth-Token: ' . $MyAccessToken));
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
$response = curl_exec($ch);
$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$headerout = curl_getinfo($ch, CURLINFO_HEADER_OUT);
curl_close($ch);
print_r($headerout);
return array($http, $response);
如果我使用hurl.it與我的價值觀它的作品沒有任何問題。