Advertisement
Guest User

Untitled

a guest
Mar 4th, 2008
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. function GetCharSheetData($userInfo, $apiURLS){
  2. $poststring = http_build_query($userInfo);
  3. $fdp = fsockopen($apiURLS['api'], 80);
  4.  
  5. fputs ($fdp, "POST " . $apiURLS['char']['CharacterSheet'] . " HTTP/1.0\r\n");
  6. fputs ($fdp, "Host: " . $apiURLS['api'] . "\r\n");
  7. fputs ($fdp, "Content-Type: application/x-www-form-urlencoded\r\n");
  8. fputs ($fdp, "User-Agent: PHPApi\r\n");
  9. fputs ($fdp, "Content-Length: " . strlen($poststring) . "\r\n");
  10. fputs ($fdp, "Connection: close\r\n\r\n");
  11.  
  12. if (strlen($poststring) > 0)
  13. fputs ($fdp, $poststring."\r\n");
  14.  
  15. $contents = "";
  16. while (!feof($fdp)){
  17. $contents .= fgets($fdp);
  18. }
  19. fclose($fdp);
  20. $start = strpos($contents, "\r\n\r\n");
  21. if ($start !== FALSE){
  22. $contents = substr($contents, $start + strlen("\r\n\r\n"));
  23. $xml = new SimpleXMLElement($contents);
  24.  
  25.  
  26. $char["characterID"] = $xml->result->characterID;
  27. $char["name"] = $xml->result->name;
  28. $char["race"] = $xml->result->race;
  29. $char["bloodLine"] = $xml->result->bloodLine;
  30. $char["gender"] = $xml->result->gender;
  31. $char["corporationName"] = $xml->result->corporationName;
  32. $char["corporationID"] = $xml->result->corporationID;
  33. if($xml->results->allianceName){
  34. $char["allianceName"] = $xml->result->allianceName;
  35. $char["allianceID"] = $xml->result->allianceID;
  36. } else {
  37. $char["allianceName"] = "None";
  38. $char["corporationID"] = 0;
  39. }
  40. $char["balance"] = $xml->result->balance;
  41. }
  42. return $char;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement