我有一个名为wrike的平台提供的代码。代码:
curl -g -X GET -H 'Authorization: bearer <token_here>'
'https://www.wrike.com/api/v3/tasks?&fields=["metadata","attachmentCount",
"parentIds","sharedIds","superParentIds","description",
"briefDescription","hasAttachments","responsibleIds","recurrent",
"superTaskIds","subTaskIds","customFields","authorIds","dependencyIds"]'
我的问题是,如何将这些代码转换为php?执行时,strike的响应是json。我不需要知道如何获取响应。(已经为其创建了代码。)我只想知道如何在php文件中使用这些代码。感谢
试试这个:(//由curl生成到PHP:http://incarnate.github.io/curl-to-php/)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.wrike.com/api/v3/tasks?&fields=['"metadata'",'"attachmentCount'",'"parentIds'",'"sharedIds'",'"superParentIds'",'"description'",'"briefDescription'",'"hasAttachments'",'"responsibleIds'",'"recurrent'",'"superTaskIds'",'"subTaskIds'",'"customFields'",'"authorIds'",'"dependencyIds'"]");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$headers = array();
$headers[] = "Authorization: bearer <token_here>";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);