Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
namespace block_configurable_reports;
3
 
4
class github extends \curl {
5
	protected $repo = '';
6
 
7
	public function set_repo($repo) {
8
		$this->repo = $repo;
9
	}
10
 
11
	/**
12
	 * Set a basic auth header.
13
	 *
14
	 * @param string $username The username to use.
15
	 * @param string $password The password to use.
16
	 */
17
	public function set_basic_auth($username, $password) {
18
		$value = 'Basic '.base64_encode($username.':'.$password);
19
		$this->setHeader('Authorization:'. $value);
20
		return true;
21
	}
22
 
23
	public function get($endpoint, $params = array(), $options = array()) {
24
		$url = 'https://api.github.com/repos/';
25
		$url .= $this->repo;
26
		$url .= $endpoint;
27
		$result = parent::get($url, $params, $options);
28
		return $result;
29
	}
30
}