繁体   English   中英

cURL PUT请求不适用于PHP

[英]cURL PUT Request Not Working with PHP

我正在使用在此处找到的Challonge.com API: https ://api.challonge.com/v1

我正在尝试使比赛更新功能正常工作-https://api.challonge.com/v1/documents/matches/update

我已经成功地使用相同的代码更新了锦标赛,但是由于某些原因,以下代码未更新变量。 相反,我得到的响应与脚本运行之前的响应相同。 有任何想法吗?

       // Update Match on Challonge
        $params = array(
            "api_key" => "my api key goes here",
            "winner_id" => "50287554",
            "scores_csv" => "2-5,1-3"               
        );
        $url = "https://api.challonge.com/v1/tournaments/efps_59/matches/78842711.json"; 
        $data_json = json_encode($params);
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($data_json)));
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
        curl_setopt($ch, CURLOPT_POSTFIELDS,$data_json);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response  = curl_exec($ch);
        curl_close($ch);
        echo $response;

您的文档指出, winner_idscores_csv的参数必须为match数组:

   // Update Match on Challonge
    $params = array(
        "api_key" => "my api key goes here",
        "match" => array(
            "winner_id" => "50287554",
            "scores_csv" => "2-5,1-3"
        )
    );

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM