RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Need Help(Yes again) - getting text from remote page then turning into a variable

Nott32

Wanderer
Need Help(Yes again) - getting text from remote page then turning into a variable

So theres a page that prints out TRUE or False depending on if a certain texts exists in the database...

(The source)
HTML:
<?xml version="1.0" encoding="ISO-8859-1"?>



<api>
	


		<gamertag>True</gamertag>


</api>

I was wondering if there was a way to read this page and if it displays True then print the desired text or if it says False then print something else...

I have been trying this:

PHP:
<?php
include 'gamercard.php';
$file = 'http://www.360voice.com/api/gamertag-leaderboard.asp?tag='.$tag;
$fp = fopen($file, 'r'); 
$users = $data;
$data = fread($fp, 80000);
$voice = "Works";
//code that will grab the list of names/password and stores it in $users

if  ($users = 'True')
{
print $voice;
} else {
print "Unfortuantly this GamerTag is not associated with the http://www.360voice.com website, so we can not display the requested information.";
}   
?>
But it just likes to put "Works" even if I use a known invalid tag
 

mordero

Knight
Wait in a database or an XML file?
For an XML file, you could parse it real quick and just get the result...
 

Nott32

Wanderer
Its the website...
http://www.360voice.com/api/gamertag-exists.asp?tag=nott32(Inserttaghere)

If your gamer tag is registered on 360voice.com it returns "True"

if it is not it returns "False"


http://www.360voice.com/api/gamertag-exists.asp?tag=nott32Nott32

will return true because I am registered with 360voice.com

I jsut need the script to read if it says true or not so that it will not display errors if it is not valid (Just come up with a set message) and if it is valid it will display another PHP page(and or text)(Using include command)

EDIT: the link I used above was incoorect....sorry

http://www.360voice.com/api/gamertag-exists.asp?tag=
 

mordero

Knight
actually it returns this
Code:
 [COLOR=#0000ff]<?xml version="1.0" encoding="ISO-8859-1" ?>[/COLOR] 
[B][FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT][/B] [COLOR=#0000ff]<!--[/COLOR] [SIZE=3][COLOR=#888888]Function to retrieve XML [/COLOR][/SIZE][COLOR=#0000ff]-->;[/COLOR] 
[B][FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT][/B] [COLOR=#0000ff]<!--[/COLOR] [SIZE=3][COLOR=#888888]requires passed XSL [/COLOR][/SIZE][COLOR=#0000ff]-->;[/COLOR] 
[URL="http://www.360voice.com/api/gamertag-leaderboard.asp?tag=Nott32#"][B][FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT][/B][/URL] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]api[/COLOR][COLOR=#0000ff]>[/COLOR]
[URL="http://www.360voice.com/api/gamertag-leaderboard.asp?tag=Nott32#"][B][FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT][/B][/URL] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]info[/COLOR][COLOR=#0000ff]>[/COLOR]
 [COLOR=#0000ff]<[/COLOR][COLOR=#990000]gamertag[/COLOR][COLOR=#0000ff]>[/COLOR][B]Nott32[/B][COLOR=#0000ff]</[/COLOR][COLOR=#990000]gamertag[/COLOR][COLOR=#0000ff]>[/COLOR] 
 
 [COLOR=#0000ff]<[/COLOR][COLOR=#990000]score[/COLOR][COLOR=#0000ff]>[/COLOR][B]1380[/B][COLOR=#0000ff]</[/COLOR][COLOR=#990000]score[/COLOR][COLOR=#0000ff]>[/COLOR] 
 
 [COLOR=#0000ff]<[/COLOR][COLOR=#990000]change[/COLOR][COLOR=#0000ff]>[/COLOR][B]0[/B][COLOR=#0000ff]</[/COLOR][COLOR=#990000]change[/COLOR][COLOR=#0000ff]>[/COLOR] 
 
 [COLOR=#0000ff]<[/COLOR][COLOR=#990000]total[/COLOR][COLOR=#0000ff]>[/COLOR][B]11[/B][COLOR=#0000ff]</[/COLOR][COLOR=#990000]total[/COLOR][COLOR=#0000ff]>[/COLOR] 
 
 [COLOR=#0000ff]<[/COLOR][COLOR=#990000]mostplayed[/COLOR][COLOR=#0000ff]>[/COLOR][B]n/a[/B][COLOR=#0000ff]</[/COLOR][COLOR=#990000]mostplayed[/COLOR][COLOR=#0000ff]>[/COLOR] 
 
 [COLOR=#0000ff]</[/COLOR][COLOR=#990000]info[/COLOR][COLOR=#0000ff]>[/COLOR]
 
 
[URL="http://www.360voice.com/api/gamertag-leaderboard.asp?tag=Nott32#"][B][FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT][/B][/URL] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]leaderboards[/COLOR][COLOR=#0000ff]>[/COLOR]
[URL="http://www.360voice.com/api/gamertag-leaderboard.asp?tag=Nott32#"][B][FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT][/B][/URL] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]leaderboard name[/COLOR][COLOR=#0000ff]="[/COLOR][B]gs[/B][COLOR=#0000ff]">[/COLOR]
 [COLOR=#0000ff]<[/COLOR][COLOR=#990000]name[/COLOR][COLOR=#0000ff]>[/COLOR][B]Top Gamerscore[/B][COLOR=#0000ff]</[/COLOR][COLOR=#990000]name[/COLOR][COLOR=#0000ff]>[/COLOR] 
 
 [COLOR=#0000ff]<[/COLOR][COLOR=#990000]rank[/COLOR][COLOR=#0000ff]>[/COLOR][B]52558[/B][COLOR=#0000ff]</[/COLOR][COLOR=#990000]rank[/COLOR][COLOR=#0000ff]>[/COLOR] 
 
 [COLOR=#0000ff]<[/COLOR][COLOR=#990000]url[/COLOR][COLOR=#0000ff]>[/COLOR][B]http://www.360voice.com/leader-gs.asp?start=52557[/B][COLOR=#0000ff]</[/COLOR][COLOR=#990000]url[/COLOR][COLOR=#0000ff]>[/COLOR] 
 
 [COLOR=#0000ff]</[/COLOR][COLOR=#990000]leaderboard[/COLOR][COLOR=#0000ff]>[/COLOR]
 
 
[URL="http://www.360voice.com/api/gamertag-leaderboard.asp?tag=Nott32#"][B][FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT][/B][/URL] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]leaderboard name[/COLOR][COLOR=#0000ff]="[/COLOR][B]gsc[/B][COLOR=#0000ff]">[/COLOR]
 [COLOR=#0000ff]<[/COLOR][COLOR=#990000]name[/COLOR][COLOR=#0000ff]>[/COLOR][B]Daily Gamerscore Change[/B][COLOR=#0000ff]</[/COLOR][COLOR=#990000]name[/COLOR][COLOR=#0000ff]>[/COLOR] 
 
 [COLOR=#0000ff]<[/COLOR][COLOR=#990000]rank[/COLOR][COLOR=#0000ff]>[/COLOR][B]45418[/B][COLOR=#0000ff]</[/COLOR][COLOR=#990000]rank[/COLOR][COLOR=#0000ff]>[/COLOR] 
 
 [COLOR=#0000ff]<[/COLOR][COLOR=#990000]url[/COLOR][COLOR=#0000ff]>[/COLOR][B]http://www.360voice.com/leader-gsc.asp?start=45417[/B][COLOR=#0000ff]</[/COLOR][COLOR=#990000]url[/COLOR][COLOR=#0000ff]>[/COLOR] 
 
 [COLOR=#0000ff]</[/COLOR][COLOR=#990000]leaderboard[/COLOR][COLOR=#0000ff]>[/COLOR]
 
 
[URL="http://www.360voice.com/api/gamertag-leaderboard.asp?tag=Nott32#"][B][FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT][/B][/URL] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]leaderboard name[/COLOR][COLOR=#0000ff]="[/COLOR][B]mpg[/B][COLOR=#0000ff]">[/COLOR]
 [COLOR=#0000ff]<[/COLOR][COLOR=#990000]name[/COLOR][COLOR=#0000ff]>[/COLOR][B]Total Games Played[/B][COLOR=#0000ff]</[/COLOR][COLOR=#990000]name[/COLOR][COLOR=#0000ff]>[/COLOR] 
 
 [COLOR=#0000ff]<[/COLOR][COLOR=#990000]rank[/COLOR][COLOR=#0000ff]>[/COLOR][B]58390[/B][COLOR=#0000ff]</[/COLOR][COLOR=#990000]rank[/COLOR][COLOR=#0000ff]>[/COLOR] 
 
 [COLOR=#0000ff]<[/COLOR][COLOR=#990000]url[/COLOR][COLOR=#0000ff]>[/COLOR][B]http://www.360voice.com/leader-mpg.asp?start=58389[/B][COLOR=#0000ff]</[/COLOR][COLOR=#990000]url[/COLOR][COLOR=#0000ff]>[/COLOR] 
 
 [COLOR=#0000ff]</[/COLOR][COLOR=#990000]leaderboard[/COLOR][COLOR=#0000ff]>[/COLOR]
 
 
 [COLOR=#0000ff]</[/COLOR][COLOR=#990000]leaderboards[/COLOR][COLOR=#0000ff]>[/COLOR]
 
 
 [COLOR=#0000ff]</[/COLOR][COLOR=#990000]api[/COLOR][COLOR=#0000ff]>[/COLOR]
if you are registered and this:
Code:
 [COLOR=#0000ff]<?xml version="1.0" encoding="ISO-8859-1" ?>[/COLOR] 
[B][FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT][/B] [COLOR=#0000ff]<!--[/COLOR] [SIZE=3][COLOR=#888888]Function to retrieve XML [/COLOR][/SIZE][COLOR=#0000ff]-->;[/COLOR] 
[B][FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT][/B] [COLOR=#0000ff]<!--[/COLOR] [SIZE=3][COLOR=#888888]requires passed XSL [/COLOR][/SIZE][COLOR=#0000ff]-->;[/COLOR] 
 [COLOR=#0000ff]<[/COLOR][COLOR=#990000]api[/COLOR] [COLOR=#0000ff]/>[/COLOR]

so you could actually just see if the result contains "<api />". If it doesnt then, the person is registered there, if it does contain it, then the person isnt registered there
 

mordero

Knight
ohhh lol, well the same thing, really there is no need to actually parse this since it is so short. Just check if the returned string contains "True" or "False"/"Invalid"
 

Nott32

Wanderer
lol *Neb alert* how would I do that?

My Attmept:

PHP:
<?php 
include 'gamercard.php'; 
$file = 'http://www.360voice.com/api/gamertag-exists.asp?tag='.$tag; 
$fp = fopen($file, 'r');  
$users = $data; 
$data = fread($fp, 80000); 
$voice = "Works"; 
//code that will grab the list of names/password and stores it in $users 

if  ($users = 'True') 
{ 
print $voice; 
} else { 
print "Unfortuantly this GamerTag is not associated with the http://www.360voice.com website, so we can not display the requested information."; 
}    
?>
 

mordero

Knight
PHP: stristr - Manual <---
PHP:
$string = "the result, whatever it may be";
if(stristr($string, 'true') === FALSE) {
   //the gamertag isnt registered here, so do that stuff
  }
else
{
//it is registered here, so do that stuff
}
 

mordero

Knight
remember when you are checking to see if something is equivalent to something else to always use at least two =, other wise, it will reassign the variable you are trying to check and if that reassignment worked (which is almost always will for variables), returns true.
 

Nott32

Wanderer
PHP:
<?php
//include 'gamercard.php';

$string = 'http://www.360voice.com/api/gamertag-exists.asp?tag=Nott32';
if(stristr($string, 'True') === FALSE) {
   echo 'IN';//the gamertag isnt registered here, so do that stuff
  }
else
{
echo 'INx';
//it is registered here, so do that stuff
}  
?>
But it cant read from the URL?
 

Malaperth

Wanderer
Frankly, I'm old, fat, and lazy, but given a chance to learn with a tool provided (by WarAngel), I think I'd try to implement a full parsing method so I could learn and make the code more easily used in the future.
 

mordero

Knight
but there isnt a reason to for that part, now once he checks if the gamertag exists and he wants to pull information from the other xml file, then yes, he should parse it, but for this, its a waste of resources
 

Nott32

Wanderer
it works :) It now checks the URL using a series of vatiables. I also figured out how to parse the gamer-leaderboards using preg_replace soI have one script that does all that and gets true/false. THanks Mordero! and thank you for the link WA.
 
Top