Laravel使用php github api创建回购协议
我正在试用这个原型应用程序,在那里我可以了解更多关于使用api和laravel的信息,所以我想到了一个使用laravel的github api的crud应用程序,到目前为止,我可以拉回购协议,没有问题,但我现在正在尝试创建一个回购协议,如果api绝地武士能够照亮一条道路,我将不胜感激 这是我在$response中从githubs api得到的消息: {“消息”:“未找到”,“文档\ url”:“}”Laravel使用php github api创建回购协议,php,laravel,github-api,Php,Laravel,Github Api,我正在试用这个原型应用程序,在那里我可以了解更多关于使用api和laravel的信息,所以我想到了一个使用laravel的github api的crud应用程序,到目前为止,我可以拉回购协议,没有问题,但我现在正在尝试创建一个回购协议,如果api绝地武士能够照亮一条道路,我将不胜感激 这是我在$response中从githubs api得到的消息: {“消息”:“未找到”,“文档\ url”:“}” 如果您刚刚开始开发,我建议您使用laravel packge for github api如果您
如果您刚刚开始开发,我建议您使用laravel packge for github api如果您刚刚开始开发,我建议您使用laravel packge for github api
public function createGithubRepo()
{
$collection = auth()->user()->providers;
$plucked = $collection->pluck('token');
$plucked->all();
$token = $plucked[0];
$url = 'https://api.github.com/repos/' . 'david-dacruz/localhost/contents/file.md';
$data = [
'message' => 'my localhost commit message',
'committer' => [
'name' => 'David Dacruz',
'email' => 'dvddcrz@gmail.com'
],
'content' => 'my localhost commit message bXkgbmV3IGZpbGUgY29udGVudHM='
];
$data = json_encode($data);
$curl_url = $url;
$curl_token_auth = 'Authorization: token ' . $token;
$ch = curl_init($curl_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'User-Agent: david-dacruz', $curl_token_auth ));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
dd($response);
curl_close($ch);
$response = json_decode($response);
return $response;
}