Advertisement
Guest User

character ID function

a guest
Apr 4th, 2020
812
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. function getCharacterIdFromName($name){
  2.     //curl -X POST "https://esi.evetech.net/latest/universe/ids/" -H "accept: application/json" -H "Accept-Language: en-us" -H "Content-Type: application/json" -d "[ \"Jehle\"]"
  3.    
  4.     //The url you wish to send the POST request to
  5.     $url = "https://esi.evetech.net/latest/universe/ids/";
  6.    
  7.     //The data you want to send via POST
  8.     $fields = array("names" => "Jehle") ;
  9.    
  10.     print_r($fields);
  11.    
  12.     //url-ify the data for the POST
  13.     $fields_string = http_build_query($fields);
  14.    
  15.     //open connection
  16.     $ch = curl_init();
  17.    
  18.     //set the url, number of POST vars, POST data
  19.     curl_setopt($ch,CURLOPT_URL, $url);
  20.     curl_setopt($ch,CURLOPT_POST, true);
  21.     curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  22.         'Accept-Language: en-us'
  23.     ));
  24.    
  25.     curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
  26.    
  27.    
  28.     // Receive server response ...
  29.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  30.    
  31.     $server_output = curl_exec($ch);
  32.     $server_output = json_decode($server_output, true);
  33.    
  34.     print_r($server_output);
  35.    
  36.     curl_close ($ch);
  37.    
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement