dsfjk44656 2013-08-27 16:00
浏览 185

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.

  • 写回答

1条回答 默认 最新

  • dongyan3237 2018-07-12 15:44
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么