Created
October 20, 2014 23:40
-
-
Save blackymetal/16d38e21a30bcac32498 to your computer and use it in GitHub Desktop.
Put data to elasticsearch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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