Arens Myzyri Arens Myzyri - 4 months ago 23
PHP Question

How to use a curl GET call code inside php

I have this code give from a platform called wrike.
Code:

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"]'


My question is, how to turn this code into php? When executed the response from strike is in json. I don't need to know how to fetch the response. (already have created the code for it.)
I just want to know how to use this code inside a php file.
Thanks

Answer

try this: (// Generated by curl-to-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);
Comments