Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…IV-Lodestone-PHP-API into dev (README.md, adding a gist for some sample JSON data).

Added specific first and last name of character accessors to getCharacterData.
  • Loading branch information
lokizilla committed Sep 23, 2013
2 parents dedd64c + 45fba54 commit 43d5671
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -10,7 +10,8 @@ Available Features
`index.php?request=characterData&characterID=[characterID]`

Returns character data for the given character ID.
Sample XML-format data for this can be found at: https://gist.github.com/lokizilla/6513918
Sample XML format data for this can be found at: `https://gist.github.com/lokizilla/6513918`
Sample JSON format data for this can be found at: `https://gist.github.com/lokizilla/6673781`
The PHP object returns data in the same layout.

Accessing via URL
Expand Down
7 changes: 4 additions & 3 deletions ffxiv-lodestone-api.php
Expand Up @@ -154,11 +154,12 @@ public function GetCharacterData($CharacterID)
$ElementsTable = $html->find('ul.param_list_elemental', 0);
$SkillLevels = $html->find('div.base_inner', 0);

$Result->CharacterName = $html->find('div.area_footer', 0)->children(2)->children(0)->plaintext;
$Result->CharacterFirstName = substr($html->find('div.area_footer', 0)->children(2)->children(0)->plaintext, 0, strpos($html->find('div.area_footer', 0)->children(2)->children(0)->plaintext, " "));
$Result->CharacterLastName = substr($html->find('div.area_footer', 0)->children(2)->children(0)->plaintext, strpos($html->find('div.area_footer', 0)->children(2)->children(0)->plaintext, " ") + 1);
$Result->CharacterFullName = $html->find('div.area_footer', 0)->children(2)->children(0)->plaintext;
$Result->CharacterRace = substr($html->find('div.chara_profile_title', 0)->plaintext, 0, strpos($html->find('div.chara_profile_title', 0)->plaintext, "/") - 1);
$Result->CharacterSubRace = substr($html->find('div.chara_profile_title', 0)->plaintext, strpos($html->find('div.chara_profile_title', 0)->plaintext, "/") + 2, (strpos(json_encode($html->find('div.chara_profile_title', 0)->plaintext), "\\n") - 2) - (strpos($html->find('div.chara_profile_title', 0)->plaintext, "/") + 2));

if (strpos($html->find('div.chara_profile_title', 0), "") !== false) $Result->CharacterGender = 'Male'; else $Result->CharacterGender = 'Female';
if (strpos($html->find('div.chara_profile_title', 0), "") !== false) $Result->CharacterGender = 'male'; else $Result->CharacterGender = 'female';
$Result->CharacterWorld = substr($html->find('div.area_footer', 0)->children(2)->children(1)->plaintext, 2, strpos($html->find('div.area_footer', 0)->children(2)->children(1)->plaintext, ")") - 2);
$Result->CharacterImage264x360 = substr($html->find('div.bg_chara_264', 0)->find('img', 0), 10, strpos($html->find('div.bg_chara_264', 0)->find('img', 0), 'width') - 12);
$Result->CharacterAvatar50x50 = substr($html->find('div.thumb_cont_black_40', 0)->find('img', 0), 10, strpos($html->find('div.thumb_cont_black_40', 0)->find('img', 0), 'width') - 12);
Expand Down

0 comments on commit 43d5671

Please sign in to comment.