Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用curl下载github存储库或文件_Php_Git_Curl_Github - Fatal编程技术网

Php 如何使用curl下载github存储库或文件

Php 如何使用curl下载github存储库或文件,php,git,curl,github,Php,Git,Curl,Github,我通过file\u get\u content成功地从github下载了一个存储库,但是curl的方向是什么呢 文件获取内容的优点类似于匿名。在这种情况下,可以在后台下载插件 但是Github将这种使用限制在10次以下,因为用户必须等待很长时间才能重新启动某些东西 如果使用curl,github似乎可以提供更多下载respository的权限 您是否有一个用于curl的示例(如anonymous) 下面是我举的一个例子。它可以正常工作,但不可能多次使用。少想10次 多谢各位 public fu

我通过
file\u get\u content
成功地从github下载了一个存储库,但是curl的方向是什么呢

文件获取内容的优点类似于匿名。在这种情况下,可以在后台下载插件

但是Github将这种使用限制在10次以下,因为用户必须等待很长时间才能重新启动某些东西

如果使用curl,github似乎可以提供更多下载respository的权限

您是否有一个用于curl的示例(如anonymous)

下面是我举的一个例子。它可以正常工作,但不可能多次使用。少想10次

多谢各位

 public function __construct() {
  $this->githubUrl = 'https://github.com';
  $this->githubApi = 'https://api.github.com';
  $this->githubRepo = 'repos';
  $this->context = stream_context_create(array('http' => array('header' => 'User-Agent: ClicShopping',)));
  $this->githubRepoClicShoppingCore = 'CoreofApplication';
  $this->githubRepoName = 'addOnNameOfApplication';
}

private function getGithubRepo() {
  $url = $this->githubApi . '/' . $this->githubRepo . '/' . $this->githubRepoName;
  return $url;
}

private function getGithubCoreRepo() {
  $url = $this->githubApi . '/' . $this->githubRepo . '/' . $this->coreName . '/' . $this->githubRepoClicShoppingCore;
  return $url;
}

private function setContext() {
  return  $this->context;
}

private function getGithubApiClicShoppingCoreArchive() {
  $url = $this->githubUrl . '/'  .$this->coreName . '/' . $this->githubRepoClicShoppingCore.'/archive/master.zip';
  return $url;
}

谢谢。

不久前做了一些类似的东西,可能是有用的(解剖它)