TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,973
  • Latest: NonStop
Stats
  • Total Posts: 196,234
  • Total Topics: 21,353
  • Online today: 639
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 254
  • Total: 254

Using APIs

Started by mrandall131, May 01, 2007, 07:39:22 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JPDeni

mrandall131, just to be sure about your article type, delete the article you have and create a new one, being sure that you create a php article from the start. Sometimes there are problems when you start with an html article and then switch to a php article.

If you still have problems, someone else will try to figure it out with you.

mrandall131

Ok, just did that.  Deleted the article, went into the article manager, clicked add php, added a title, pasted this code into it


define('XML_DECLARATION', '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n");

$name_v = array();
$points_v = array();


$tag = "MuddyEiger";
$file = "http://www.360voice.com/api/games-listfav.asp?tag=MuddyEiger&num=10";
$open = $file;
if (!($xml = domxml_open_file($open,
  DOMXML_LOAD_PARSING + //0
  DOMXML_LOAD_COMPLETE_ATTRS + //8
  DOMXML_LOAD_SUBSTITUTE_ENTITIES + //4
  DOMXML_LOAD_DONT_KEEP_BLANKS
  ,$error))) {
  echo "Document Could not be Read.<br />".$file."<br />".$tag."<br />";
  exit;
}

$xmldoc = domxml_open_mem($xml,
  DOMXML_LOAD_PARSING + //0
  DOMXML_LOAD_COMPLETE_ATTRS + //8
  DOMXML_LOAD_SUBSTITUTE_ENTITIES + //4
  DOMXML_LOAD_DONT_KEEP_BLANKS
  );
$elements = $xml->get_elements_by_tagname("game");


for($i = 0; $i < count($elements); $i++) {
  $element = $elements[$i];
  $child = $element->first_child();
  while($child) {
   if ($child->tagname == 'name') { $name_v[] = $child->get_content(); }
   if ($child->tagname == 'currentgs') {$points_v[] = $child->get_content(); }
   if ($child->tagname == 'totalgs') {$totals_v[] =  $child->get_content(); }
   if ($child->tagname == 'tile') {$tiles_v[] = $child->get_content(); }
  if ($child->tagname == 'percentcomplete') {$complete_v[] = $child->get_content(); }
   $child = $child->next_sibling();
   //echo $child->tagname . "<br />";
  }
}

for($i = 0; $i < count($elements); $i++) {
echo $name_v[$i];
echo "<br /><img src='".$tiles_v[$i]."'>";
echo "<br />Current Score: ".$points_v[$i]."/".$totals_v[$i];
echo "<br />Percent Complete: ".$complete_v[$i]."<br /><br />";
}

xml_parser_free($xmldoc);


and this is what the article looked like on the front page.

JPDeni

Now delete the code. Save the page. Paste the code in again. Save it again. See what happens.

That's the last thing that I can think of.

mrandall131

Tried, about 5 times so far.  For some reason, it's not seeing it as PHP.  For now, I created a blank article.  Then, I created a block with the PHP in it, as it works in a block.  Then, I made the block display when the blank article is clicked on.  Round about way, but at least it does what I need it to.

http://www.killingauthority.com/index.php?page=13

This website is proudly hosted on Crocweb Cloud Website Hosting.