GIT API:项目访问请求

时间:2018-09-26 13:19:46

标签: gitlab

我正在尝试使用PHP-CURL执行此GIT API,但会引发如下错误:

  

POST / projects /:id / access_requests

     

[消息] => 403禁止

https://docs.gitlab.com/ee/api/access_requests.html#request-access-to-a-group-or-project

这是我的示例代码:

$url = $url.'projects/'.$id.'/access_requests';
$fields = array('id' => $id);
$token = 'my-git-token';

$ch = curl_init();

//set the url, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('PRIVATE-TOKEN: '.$token));

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($fields));


//execute post
$response = curl_exec($ch);        
//close connection
curl_close($ch);        

if(!$response) {
    return false;
}       

$decode_arr = json_decode($response,1);

有人可以帮忙吗?

0 个答案:

没有答案