blob: b15a56c67eaa6ef50e77c43676221240cb62ae77 (
plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
<?php
class simpleCurlWrapper {
private $ch;
public $result;
public function __construct($url = false, $options = array()){
if( ! $url ){
return;
}
$this->init($url, $options);
}
public function init($url = false, $options = array(), $exec = false){
if( ! $url ){
return false;
}
$this->ch = curl_init( $url );
$this->setOptions( $options );
if ( $exec ){
$this->exec();
}
}
public function setOption($param = false, $value = false){
if ( ! $param && ! $value ){
return;
}
curl_setopt($this->ch, $param, $value);
}
public function setOptions( $options = array() ){
if ( ! empty( $options ) ){
foreach( $options as $key => $value ){
$this->setOption($key, $value);
}
}
}
public function exec(){
$this->result = curl_exec( $this->ch );
}
public function getInfo($param){
return curl_getinfo($this->ch, $param);
}
public function setRequestMethod( $string ){
$request = strtolower( $string );
switch( $string ){
case("head"):
break;
case("post"):
break;
case("get"):
break;
case("put"):
break;
case("delete"):
break;
default:
return false;
}
}
public function setUserAgent($string){
return curl_setopt( $this->ch, CURLOPT_USERAGENT, $string );
}
public function getStatusCode(){
return curl_getinfo( $this->ch, CURLOPT_HTTPHEADER);
}
public function __destruct(){
curl_close( $this->ch );
}
}
|