【发布时间】:2019-07-07 02:11:15
【问题描述】:
Objetcive:尝试在 zoho workdrive 中创建一个文件,使用 php-curl
注意:我已经检查了 oauth 并且我正在使用正确的 oauth。 另外,我使用了正确的父 ID。
error-recieved : {"errors":[{"id":"F000","title":"GeneralException"}]}
使用的代码:
work_drive_create_file($oauth);
function work_drive_create_file($oauth){
$apiUrl = "https://workdrive.zoho.com/api/v1/files";
$data ='{
"data": {
"attributes": {
"name": "Untitled Spreadsheet",
"service_type": "zohosheet",
"parent_id": "0nk78318a1771da934f22939e4a00d8aab225"
},
"type": "files"
}
}';
$headers = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data),
sprintf('Authorization: Zoho-oauthtoken %s', $oauth)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_POSTFIELDS ,$data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
$response = curl_exec($ch);
print_r(json_decode($response));
curl_close($ch);
return $response;
}
我也想知道“服务类型”的值,如果它是一个代替 zohosheet 的文档。
【问题讨论】:
标签: zoho