Skip to content

Instantly share code, notes, and snippets.

@blackymetal
Created October 20, 2014 23:40
Show Gist options
  • Select an option

  • Save blackymetal/16d38e21a30bcac32498 to your computer and use it in GitHub Desktop.

Select an option

Save blackymetal/16d38e21a30bcac32498 to your computer and use it in GitHub Desktop.
Put data to elasticsearch
private function put($data) {
// Open connection
$ch = curl_init();
$url = 'http://127.0.0.1:9200/colombia/bogota/'.$data['id'];
// Set the url, number of POST vars, POST data
curl_setopt( $ch, CURLOPT_URL, $url );
// curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $data ) );
// Execute post
$result = curl_exec($ch);
debug($result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment