public function testPutFileHandle() { $png = $this->create_png(); $tmp_file = $this->create_tmp_file($png); $this->curl->setOpt(CURLOPT_PUT, TRUE); $this->curl->setOpt(CURLOPT_INFILE, $tmp_file); $this->curl->setOpt(CURLOPT_INFILESIZE, strlen($png)); $this->curl->put(self::TEST_URL . '/server.php', array('test' => 'put_file_handle')); fclose($tmp_file); $this->assertTrue($this->curl->response === 'image/png'); }
/** * @param $filePath * @param null $size * * @return mixed * @throws Exception */ public function putFile($filePath, $size = null) { $resource = fopen($filePath, 'r'); $response = $this->curl->put($resource, $size ? $size : filesize($filePath))->execute(); fclose($resource); return $response; }
public function setTimes($path, $modificationTime = '', $accessTime = '') { $url = $this->_buildUrl($path, array('op' => 'SETTIMES', 'modificationtime' => $modificationTime, 'accesstime' => $accessTime)); return Curl::put($url); }
private function _call($call, $data = FALSE, $type = FALSE) { switch ($type) { case "post": $curl = new Curl(); $url = $this->api_host . $call . "?key={$this->key}"; $response = $curl->post($url, $data); $response = json_decode($response->body); return $response; break; case "put": $curl = new Curl(); $url = $this->api_host . $call . "?key={$this->key}"; $response = $curl->put($url, $data); $response = json_decode($response->body); return $response; break; case "delete": $curl = new Curl(); $url = $this->api_host . $call . "?key={$this->key}"; $response = $curl->request('DELETE', $url, $data); $response = json_decode($response->body); return $response; break; default: $data["key"] = $this->key; $curl = new Curl(); //$url = $this->api_host . $call . "?key=$this->key"; $url = $this->api_host . $call; $response = $curl->get($url, $data); $response = json_decode($response->body); return $response; break; } }
public static function put($path, $data) { $curl = new Curl(); $curl->put(\Slim\Slim::getInstance()->globalConfig['oaUrl'] . $path, $data); return json_decode($curl->response->form, TRUE); }
public function put($resource, array $params = array()) { $url = $this->buildUrl($resource); $curl = new Curl(); return $curl->put($url, $params); }
- redefine $url to point to the location of this file, eg http://localhost/test.php - run this script by browsing to it and appending a 'run' parameter to the url, eg http://localhost/test.php?run */ $url = 'http://localhost/~pandayak/curl/test.php'; if (isset($_GET['run'])) { require 'curl.php'; $c = new Curl(); //test default behavior $param = 'qwe'; $test = $c->get($url, array('param' => $param)); assert($param == $test); $param = 'asd'; $test = $c->post($url, array('param' => $param)); assert($param == $test); $param = 'zxc'; $test = $c->put($url, array('param' => $param)); assert($param == $test); $param = '123'; $test = $c->delete($url, array('param' => $param)); assert($param == $test); //test multi behavior w/ single requests $param = 'qwe'; $test = $c->multi(array(array('get', $url, array('param' => $param)))); assert($param == $test[0]); $param = 'asd'; $test = $c->multi(array(array('post', $url, array('param' => $param)))); assert($param == $test[0]); $param = 'zxc'; $test = $c->multi(array(array('put', $url, array('param' => $param)))); assert($param == $test[0]); $param = '123';
<?php require '../src/Curl.class.php'; // curl -X PUT -d "id=1&first_name=Zach&last_name=Borboa" "http://httpbin.org/put" $curl = new Curl(); $curl->put('http://httpbin.org/put', array('id' => 1, 'first_name' => 'Zach', 'last_name' => 'Borboa')); echo 'Data server received via PUT:' . "\n"; var_dump($curl->response->form);