Location: PHPKode > scripts > ezStats for PlayStation Network > ezStats2_psn/admin/apitest.php
<?php
	error_reporting (E_ALL|E_STRICT);
	
	require '../tmp/sql.php';
	require '../classes/mysql.php';
	require '../classes/settings.php';
	require '../classes/security.php';
	require '../classes/functions.php';
	require '../classes/session.php';
	require '../classes/login.php';
	require '../classes/template.php';
	require '../classes/player.php';
	require '../classes/stats.php';
	require '../classes/signatures.php';
	require '../classes/psn.php';
	
	
	// Navigation
	echo '<a href="apitest.php?info">PHP-Info</a><br/>';
	echo '<a href="apitest.php?more">Settings</a><br/>';
	echo '<a href="apitest.php?curl">cURL Test</a><br/>';
	echo '<a href="apitest.php?psn">PSN Test</a><br/>';
	echo '<br/><br/><br/>';
	
	
	// PHP-Info
	if (isset($_GET['info'])) {
		die(phpinfo());
	}
	
	
	// Settings
	if (isset($_GET['more'])) {
		$settings = new Settings();
		echo "<br/>Ident: ".$settings->get('ident');
		echo "<br/>Key: ".$settings->get('key');
		echo "<br/>Path: ".$settings->get('path');
		die();
	}
	
	
	// cURL-Test
	if (isset($_GET['curl'])) {
		$postdata = Array(
			'player' => 'ezzemm',
			'opt' => 'clear,global'
		);
		
		// BF3STATS-API
		$c=curl_init('http://api.bf3stats.com/pc/player/');
		curl_setopt($c,CURLOPT_HEADER,false); curl_setopt($c,CURLOPT_POST,true); curl_setopt($c,CURLOPT_USERAGENT,'BF3StatsAPI/0.1'); curl_setopt($c,CURLOPT_HTTPHEADER,array('Expect:')); curl_setopt($c,CURLOPT_RETURNTRANSFER,true); curl_setopt($c,CURLOPT_CONNECTTIMEOUT,5); curl_setopt($c,CURLOPT_POSTFIELDS,$postdata);
		
		$result = curl_exec($c);
		$status = curl_getinfo($c,CURLINFO_HTTP_CODE); $error = curl_error($c); $errno = curl_errno($c);
		curl_close($c);
		
		echo "<br><br>BF3STATS:<br>Status: $status<br>Error: $error ($errno)<br>Result: $result";
		
		
		// THIS PAGE
		$settings = new Settings();
		$c=curl_init($settings->get('path').'/admin/apitest.php');
		curl_setopt($c,CURLOPT_HEADER,false); curl_setopt($c,CURLOPT_POST,true); curl_setopt($c,CURLOPT_USERAGENT,'BF3StatsAPI/0.1'); curl_setopt($c,CURLOPT_HTTPHEADER,array('Expect:')); curl_setopt($c,CURLOPT_RETURNTRANSFER,true); curl_setopt($c,CURLOPT_CONNECTTIMEOUT,5); curl_setopt($c,CURLOPT_POSTFIELDS,$postdata);
		
		$result = curl_exec($c);
		$status = curl_getinfo($c,CURLINFO_HTTP_CODE); $error = curl_error($c); $errno = curl_errno($c);
		curl_close($c);
		
		echo "<br><br>THIS PAGE:<br>Status: $status<br>Error: $error ($errno)<br>Result: $result";
		
		
		// EZSTATS
		$c=curl_init('http://curl.ezstats.org/?version');
		curl_setopt($c,CURLOPT_HEADER,false); curl_setopt($c,CURLOPT_POST,true); curl_setopt($c,CURLOPT_USERAGENT,'BF3StatsAPI/0.1'); curl_setopt($c,CURLOPT_HTTPHEADER,array('Expect:')); curl_setopt($c,CURLOPT_RETURNTRANSFER,true); curl_setopt($c,CURLOPT_CONNECTTIMEOUT,5); curl_setopt($c,CURLOPT_POSTFIELDS,$postdata);
		
		$result = json_decode(curl_exec($c));
		$status = curl_getinfo($c,CURLINFO_HTTP_CODE); $error = curl_error($c); $errno = curl_errno($c);
		curl_close($c);
		
		echo "<br><br>EZSTATS:<br>Status: $status<br>Error: $error ($errno)<br>Result: $result";
		
		die();
	}
	
	
	// PSN Test
	if (isset($_GET['psn'])) {
		date_default_timezone_set('Europe/Paris');
		$psn = New PSN(); // Starts the class
		
		$new = $psn->get_jid('Dante2582'); // this function will turn a name like DoSe420 into its PSN jid such as hide@address.com and the users region which is needed for the get_prof function
		$getProf = $psn->get_prof($new['region'], $new['jid']); // this function will return the Profile info such as, Username (DoSe420), Country, Aboutme, Avatar, Color (The background color on the users psn profile), and PS+ Status
		$getCount = $psn->get_count($new['jid']); // this function will return the total trophy counts for, Platinum, Gold, Silver, and Bronze, as well will return the Current Level, Level Progress, Points, Base Points (Points for start of the level), Next Level (Points needed for the next level), also i have added an extra line to total all the trophies together for an overall ammount.
		$games = $psn->get_games($new['jid']); // this function will return the list of games played. This info is limited to npcommid (Games ID), Trophy counts for each game (Platinum, Gold, Silver, Bronze Earned), LastUpdated (The time it was last synced, used for play order), and i have added a line to total the Trophy Counts for each game.
		$trophyList = $psn->get_trophies($new['jid'], $games[0]['npcommid']); // this function will return the list of trophies for whatever is inserted in $npcommid. You would get the npcommid and store them using the get_games function then call them using this function. This function will get you the Trophyid (Which is the # in order), Trophy Type (Platinum, Gold, Silver, Bronze), Trophy Date (The date the trophy was earned shown is strtotime format)
		
		echo '<pre>';
		print_r($new);
		print_r($getProf);
		print_r($getCount);
		print_r($games);
		//print_r($trophyList);
	}
?>














Return current item: ezStats for PlayStation Network