php-curl支持'PATCH'吗?

时间:2012-07-17 23:38:31

标签: php curl

我正在使用php和curl来测试rest api,特别是'PATCH'。 当我运行下面的代码时,我得到的输出是:{“code”:“InvalidContent”,“message”:“无效的JSON:意外的令牌\ n”}

我错过了什么?我们可以通过https进行卷曲补丁吗?访问令牌我是有效的,适用于所有其他apis。

我有以下代码:

<?php

     $url = 'https://a-q.abc.co/docs/<ean>';

     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH" ); 
     curl_setopt($ch, CURLOPT_HTTPHEADER,  
     array('Authorization: Bearer <access_token>=', 'Accept-Version: ~1','Content-Type: application/json')); 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLINFO_HEADER_OUT, true);
     curl_setopt ($ch, CURLOPT_POSTFIELDS,'{"title": "
     script Ran", "authors":[{"firstName":"12344", "lastName":"dddd"}],"description":"Script Document"}');
     $response = curl_exec($ch);
    if(!CURL_ERROR($ch)){
        echo"\n The output is:".$response;
    }else{
        echo "\n Fetch failed ".curl_error($ch);
        exit;
    }

  curl_close($ch);

?>

0 个答案:

没有答案