<pre> <? /* * readUserStats(userid) * - Read WhatPulse user statistics from the webapi into an array. * * Author: wasted@whatpulse.org */ function readUserStats($userid) { // prepare an array to hold your stats // types of statistics "DateJoined", "Homepage", "LastPulse", "Pulses", "TotalKeyCount", "TotalMouseClicks", "AvKeysPerPulse", "AvClicksPerPulse", "AvKPS", "AvCPS", "Rank", "TeamID", "TeamName", "TeamMembers", "TeamKeys", "TeamClicks", "TeamDescription", "TeamDateFormed", "RankInTeam", "GeneratedTime"); // init the xml parser and read the data into an array $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, $data, $values, $tags); xml_parser_free($parser); // loop through the structures foreach ($tags as $key => $val) { // only process stuff between the <UserStats> tags if ($key == "UserStats") { // loop through the tags inside <UserStats> $ranges = $val; { $offset = $ranges[$i] + 1; $len = $ranges[$i + 1] - $offset; // loop through the structure of the xml tag foreach($statsarray as $key => $value) { // match to a stats_type { if($value['tag'] == $stat_types[$i]) { // remember the value of the stats_type $type = $stat_types[$i]; $WhatPulseStats[$type] = $value['value']; } } } } } else { continue; } } return $WhatPulseStats; } // read statistics $stats = readUserStats(155348); ?> </pre>
Z góry thx za pomoc
----------
Dla kodu php uzywaj [php] nie [code]
-- dr_bonzo