コード例 #1
0
ファイル: ClientController.php プロジェクト: trice4/BlogTest
 public function request_delete($id)
 {
     $link = Router::url('/', true) . 'rest_posts/' . $id . '.json';
     $data = null;
     $httpSocket = new HttpSocket();
     $response = $httpSocket->delete($link, $data);
     $this->set('response_code', $response->code);
     $this->set('response_body', $response->body);
     $this->render('/Client/request_response');
 }
コード例 #2
0
 public function request_delete($id)
 {
     // remotely post the information to the server
     $link = "http://" . $_SERVER['HTTP_HOST'] . $this->webroot . 'rest_tasks/' . $id . '.json';
     $data = null;
     $httpSocket = new HttpSocket();
     $response = $httpSocket->delete($link, $data);
     $this->set('response_code', $response->code);
     $this->set('response_body', $response->body);
     $this->render('/Client/request_response');
 }
コード例 #3
0
 /**
  * HTTP上で要求の送信
  * @param string $url
  * @param array $data
  * @param string $type
  */
 private function sendRequest($url, $data, $type = 'post')
 {
     $http = new HttpSocket();
     if ($type == 'post') {
         $response = $http->post($url, $data);
     } else {
         if ($type == 'get') {
             $response = $http->get($url, $data);
         } elseif ($type == 'delete') {
             $response = $http->delete($url, $data);
         }
     }
     return json_decode($response->body);
 }
コード例 #4
0
 public function delete($id)
 {
     // remotely post the information to the server
     $link = "http://" . $_SERVER['HTTP_HOST'] . $this->webroot . 'posts/' . $id . '.json';
     $data = null;
     $httpSocket = new HttpSocket();
     // $data['Post']['title']="this is updated title";
     //$data['Post']['content']="this is updated content";
     $response = $httpSocket->delete($link, $data);
     $this->set('response_code', $response->code);
     $this->set('response_body', $response->body);
     $this->set('link', $link);
     $this->render('/client/request_response');
 }
コード例 #5
0
ファイル: Event.php プロジェクト: HardlyHaki/MISP
 /**
  * Deletes the event and the associated Attributes from another Server
  * TODO move this to a component
  *
  * @return bool true if success, error message if failed
  */
 public function deleteEventFromServer($uuid, $server, $HttpSocket = null)
 {
     // TODO private and delete(?)
     $url = $server['Server']['url'];
     $authkey = $server['Server']['authkey'];
     if (null == $HttpSocket) {
         App::uses('HttpSocket', 'Network/Http');
         $HttpSocket = new HttpSocket();
     }
     $request = array('header' => array('Authorization' => $authkey, 'Accept' => 'application/xml', 'Content-Type' => 'application/xml'));
     $uri = $url . '/events/0?uuid=' . $uuid;
     // LATER validate HTTPS SSL certificate
     $this->Dns = ClassRegistry::init('Dns');
     if ($this->Dns->testipaddress(parse_url($uri, PHP_URL_HOST))) {
         // TODO NETWORK for now do not know how to catch the following..
         // TODO NETWORK No route to host
         $response = $HttpSocket->delete($uri, array(), $request);
         // TODO REST, DELETE, some responce needed
     }
 }
コード例 #6
0
 /**
  * Make a delete request to the api
  * @param  string $url  relative to the base
  * @param  array $data 
  * @return array
  */
 public function delete($url, $data = array())
 {
     $http = new HttpSocket();
     return $this->process($http->delete($this->apiBase . $url . '?' . http_build_query($this->_params($data))));
 }