Metal Gear Online Stats

This involves programming not gaming.

Page 1 of 1

4 Replies - 1619 Views - Last Post: 17 February 2009 - 01:33 PM

#1 grimpirate  Icon User is offline

  • Pirate King
  • member icon

Reputation: 149
  • View blog
  • Posts: 714
  • Joined: 03-August 06

Metal Gear Online Stats

Post icon  Posted 15 February 2009 - 01:18 PM

Alright, this is going to take a little bit of explaining.

First off, Metal Gear Online. This is the initial page of the Metal Gear Online Community Support Page.

Secondly, what I want to do is utilizing PHP read the stats that this page makes available about your record on Metal Gear Online (obviously I need to log in with my particular user information).

The purpose? To make a graphical gamer card of my metal gear online info. Any ideas how to proceed? I tried utilizing POST but it doesn't seem to work that way, and for the life of me I can't understand what exactly the javascript is supposed to be doing.

This post has been edited by grimpirate: 15 February 2009 - 01:28 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Metal Gear Online Stats

#2 Nykc  Icon User is offline

  • Gentleman of Leisure
  • member icon

Reputation: 731
  • View blog
  • Posts: 8,644
  • Joined: 14-September 07

Re: Metal Gear Online Stats

Posted 15 February 2009 - 02:39 PM

I am assuming you are trying to accomplish something similar to my Gamer Card or one of the PC gaming communities we have a stats card for Delta Force. I would be curious as well to see how this is done as I have always wanted to make my own.

This might not be exactly what you are looking for but hopefully it will help nudge you in the right direction if anything...
http://www.phpmix.or...namic_signature

You would probably get a better response in the game programming forum section instead of the games discussion forum though.
Was This Post Helpful? 0
  • +
  • -

#3 grimpirate  Icon User is offline

  • Pirate King
  • member icon

Reputation: 149
  • View blog
  • Posts: 714
  • Joined: 03-August 06

Re: Metal Gear Online Stats

Posted 15 February 2009 - 03:10 PM

Yeah thanks for the reply NyKc. I already know how to work with gd though. However, my specific problem isn't the image creation. I appreciate that tutorial, it'll give me something to reference should I need to.

What I need to know is how to gain access into my stats, in other words a sort of virtual login. Once, I'm there I'm pretty sure I can figure out how to parse what I need out of the text. Unfortunately, MGO doesn't provide some sort of API for accessing that data, like an XML sheet or something.

I'm just hoping someone who plays MGO (or another game with a similar stat interface) and has experience with making requests of this nature can figure out a way to get me to log in, or specifically to the page with the stats. I'd gladly take care of anything else.

Yes I considered putting in game programming, but since I wasn't programming a game I figured what the hell, lemme try here. In any case, if any mods/ops think it would be better served there, please move it there.
Was This Post Helpful? 0
  • +
  • -

#4 grimpirate  Icon User is offline

  • Pirate King
  • member icon

Reputation: 149
  • View blog
  • Posts: 714
  • Joined: 03-August 06

Re: Metal Gear Online Stats

Posted 15 February 2009 - 03:44 PM

Come to think of it. Here's the code I was using just so I don't get accused of being lazy:
function post_request($url, $data, $headers = null){

	$data = http_build_query($data);
	
	$context_options = array (
		'http' => array (
			'method' => 'POST',
			'header'=> "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen($data) . "\r\n",
			'content' => $data
		)
	);
	
	if(!isset($headers))
		$params['http']['header'] = $headers;
	
	$context = stream_context_create($context_options);
	
	if(false === $fp = @fopen($url, 'rb', false, $context))
		return !trigger_error('Unable to open url', E_USER_NOTICE);
		
	if(false === $response = @stream_get_contents($fp))
		return !trigger_error('Unable to read from url', E_USER_NOTICE);
		
	return $reponse;
}
Essentially it just lets me make a POST request.

This post has been edited by grimpirate: 15 February 2009 - 03:44 PM

Was This Post Helpful? 0
  • +
  • -

#5 grimpirate  Icon User is offline

  • Pirate King
  • member icon

Reputation: 149
  • View blog
  • Posts: 714
  • Joined: 03-August 06

Re: Metal Gear Online Stats

Posted 17 February 2009 - 01:33 PM

Alright, well I've made some progress. Not much, but I managed to get up to the agreement page. Here's the code thus far:
<?php
$url = 'http://mgo2sns.konamionline.com/us/community/?m=pc&a=page_o_top&resolution=hd';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);

$start = strpos($data, 'PHPSESSID');
$end = strpos($data, ';', $start);
$data = substr($data, $start, $end - $start);
$refurl = $url;
$url = 'http://mgo2sns.konamionline.com/us/community/';

$postfields = array();
$postfields[] = array("m", 'pc');
$postfields[] = array("a", 'page_o_agree');
$postfields[] = array("lang", 'us');
$postfields[] = array("resolution", 'hd');

foreach($postfields as $subarray) {
	list($foo, $bar) = $subarray;
	$bar = urlencode($bar);
	$postedfields[] = "$foo=$bar";
}

$urlstring = join("&", $postedfields);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $urlstring);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_REFERER, $refurl);
curl_setopt($ch, CULROPT_COOKIE, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);

print_r($data);
?>
The issue is that now if I attempt to go to navigate to the page after that, which is the login page, I get returned to the beginning page, the javascript page that determines screen resolution. I think it may be because the login page is an https as opposed to an http page. Not sure how to proceed here. Any ideas?

To a mod: If you could please move this to the PHP forum as I think that's what this thread is slowly becoming.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1