-
Notifications
You must be signed in to change notification settings - Fork 0
/
beanstalker.class.php
49 lines (41 loc) · 1.01 KB
/
beanstalker.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?
class Beanstalker {
function Beanstalker($settings=null){
if(isset($settings)){
$this->config($settings);
}
}
function config($settings){
if(!isset($settings['format'])){
$settings['format'] = 'array';
}
$this->domain = $settings['domain'];
$this->login = $settings['login'];
$this->password = $settings['password'];
$this->format = $settings['format'];
switch($this->format){
case 'array':
require_once('xml2array.function.php');
break;
}
}
function RepositoryFind(){
$url = 'http://'.$this->domain.'.beanstalkapp.com/api/repositories.xml';
$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode("$this->login:$this->password")
)
));
$data = file_get_contents($url, false, $context);
return $this->ret($data);
}
function ret($data){
switch($this->format){
case 'array';
return xml2array($data);
default:
return $data;
}
}
}
?>