0

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

1
  • The next time try to format the code in order it is visible without scrolling it for hours. Check how I edited your code section. Commented Jul 30, 2016 at 13:26

1 Answer 1

1

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);
Sign up to request clarification or add additional context in comments.

3 Comments

You sir are an HERO. Thanks
I don't understand why did they vote me -2. Anyway you resolved 100% my question, and it worked.
the "gurus" feel this is probably too basic question :P

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.