3 class image_uploader{
\r
4 public $responseInfo;
\r
5 public $type = 'xml';
\r
6 public $user_agent = 'rabr';
\r
8 public function imgly($image){
\r
9 $postdata = array( 'media' => "@$image");
\r
10 $request = 'http://img.ly/api/upload';
\r
11 return $this->objectify( $this->process( $request, $postdata ) );
\r
14 /**** request method ****/
\r
15 function process($url,$postargs=false)
\r
17 $ch = curl_init($url);
\r
18 curl_setopt($ch, CURLOPT_HTTPHEADER, array("Expect:"));
\r
20 if($postargs !== false)
\r
22 curl_setopt ($ch, CURLOPT_POST, true);
\r
23 curl_setopt ($ch, CURLOPT_POSTFIELDS, $postargs);
\r
25 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
\r
26 curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent);
\r
27 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
\r
29 $response = curl_exec($ch);
\r
31 $this->responseInfo=curl_getinfo($ch);
\r
33 return $this->responseInfo['http_code'];
\r
34 if( intval( $this->responseInfo['http_code'] ) == 200 )
\r
40 function objectify( $data )
\r
42 if( function_exists('simplexml_load_string') ) {
\r
43 $obj = simplexml_load_string( $data );
\r
45 if (isset($obj->error) || !$obj) return false;
\r