Redmine REST API,使用PHP更新问题

I am new to APIs and I am having trouble updating the status of issues. I have successfully listed projects and issues but not sure how to update them. I am using PHP to access the API. Can some one please share some example in php to how to update an issue using json. I have read the API documentation but its too minimal. I am not familiar with PUT and I cant find any good example or tutorial on the internet. Thankyou!

This what I tried but didnt work

function update_issue($issue_id){
    // set url
    $planio_url = "http://something.plan.io/issues/".issue_id.".json?key=185f1edsadfsdafy86578ce82ea70a0eb4267";

    // create curl resource
    $ch = curl_init();

    $data = '{"issue":{"status":{"name":"done","id":21},"notes":"closing all old issues"}}';
    $data = json_decode($data);

    $ch = curl_init($planio_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
    curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data));

    $response = curl_exec($ch);

    if(!$response) {
        return false;
    }else{
        return $response;
    }
}

Returns empty response.

For everybody who wants to copy the snippet above. to update a ticket (like i did)

The URL in $planio_url is missing a $

..issues/".issue_id.".json

must be:

issues/".$issue_id.".json

also i decoded the json with true as second parameter to get an array for http_build_query

works like a charm.