PHP 및 CURL 호출을 사용하여 Dropbox v2 API 호출에 액세스 해보십시오. 여기 모래 상자 https://dropbox.github.io/dropbox-api-v2-explorer/#files_search에 따라 "쇼 코드"는 다음과 같습니다. 내가 그것을 실행하면Dropbox v2 API PHP CURL 호출 문제 해결
curl -X POST https://api.dropboxapi.com/2/files/search \
--header 'Authorization: Bearer myAccessTokenHere \
--header 'Content-Type: application/json' \
--data '{"path":"/My Cars","query":"\".j\"","start":0,"max_results":50}'
내 PHP 코드는 내가
응답 = 얻을이
function performSearch() { $cheaders = array("Authorization: Bearer myAccessTokenHere", 'Content-Type: application/json', 'Dropbox-API-Arg: {"path":"/My Cars","query":"\".j\"","start":"0","max_results":"50"}'); $ch = curl_init('https://content.dropboxapi.com/2/files/search'); curl_setopt($ch, CURLOPT_HTTPHEADER, $cheaders); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); echo "\n response = $response"; curl_close($ch); }
처럼 보이는 { "오류": "찾을 수 없음"}
응답 해 주셔서 감사합니다 이 코드는 오류와 함께 반환됩니다. 어떤 부분에 대해 이야기하고 있는지 확실하지 않습니다. 응답 = API 함수 "파일/검색"에 대한 호출 오류 : 요청 본문 : 입력을 JSON으로 디코딩 할 수 없습니다 – JMoskwa
오류는 귀하의 요청 본문에있는 JSON (즉, AP에 대한 매개 변수 내가 부름)이 유효하지 않습니다. ''\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ , ""\ "start \": 0, \ "max_results \": 50} ") – Greg