Jump to content

PSN Freinds List Data


MrLee

Recommended Posts

Hi everyone, im looking for some help if anyone can offer it.

 

I currently run a phpbb Playstation3 gaming forum and was looking for a way to show forum members online status info on a seperate page on my forum.

 

I found some php script that pulls the freinds list data from the URL mentioned in the code, for now it only works on my local host and i get errors when trying to run it from my live server.

 

here is the current code:

<?php


error_reporting(E_ALL);


libxml_use_internal_errors(true);
$fp = fopen("curl_log.txt",'a+');  //Logging purposes only

$dataURL     = "https://secure.eu.playstation.com/ajax/mypsn/friend/presence";
$loginURL     = "https://store.playstation.com/external/login.action?returnURL=https://secure.eu.playstation.com/sign-in/confirmation";


$cc = curl_init();

getData();

function getData()
{
   
   global $cc,$fp,$dataURL;
   
   curl_setopt ($cc, CURLOPT_URL, $dataURL);
   curl_setopt ($cc, CURLOPT_POST, 0);
   curl_setopt ($cc, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt ($cc, CURLOPT_FOLLOWLOCATION, 1);
   curl_setopt ($cc, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7');
   curl_setopt ($cc, CURLOPT_SSL_VERIFYPEER, 0);
   curl_setopt ($cc, CURLOPT_REFERER, $dataURL);
   curl_setopt ($cc, CURLOPT_VERBOSE, 1);
   curl_setopt ($cc, CURLOPT_STDERR, $fp);
   curl_setopt ($cc, CURLOPT_COOKIEFILE, 'cookie.txt');

   $output = curl_exec($cc);

   $xml = simplexml_load_string($output);

   if (!$xml)
   {
       login();
   }
   else
   {
       
              // Here you will have a simpleXML object that you can do with as you please - example output below.

               foreach($xml->psn_friend as $friend)
       {
           $img_loc = str_replace("//", "/", $friend->current_avatar);
   echo "<img src=\"https://secure.eu.playstation.com".$img_loc."\"/> ";
echo "<font color=\"red\">$friend->onlineid</font> <br />";
echo "Status : ".$friend->current_presence."<BR />";
           echo "Game : ".$friend->current_game."<BR />";
           echo "Comment : ".$friend->Comment."<BR />";
   
           echo "<BR /><BR />";
       }
       
       curl_close($cc);
       fclose($fp);    
   }
}

function login()
{
   global $cc,$loginURL;
   
   curl_setopt ($cc, CURLOPT_URL, $loginURL);
   curl_setopt ($cc, CURLOPT_POST, 1);
   curl_setopt ($cc, CURLOPT_POSTFIELDS, 'loginName=<username@user.com>&password=<password>');
   curl_setopt ($cc, CURLOPT_COOKIEJAR, 'cookie.txt');
   
   curl_exec($cc);
   
   getData();
}

?>

 

The error i mentioned above is related to the

curl_setopt ($cc, CURLOPT_FOLLOWLOCATION

command, im not to concerned about that at the moment.

 

Im looking for someone to help me with the actually XML object, its very basic and i would, if poss, love to have it looking like the actual PSN freinds list. Here are images of this codes output and the actuall Freinds list.

 

Codes Ouput:

Mypsn.png

 

Actuall PSN FR:

PSNFreindslist.png

 

Would it be possable to actually grab the exact image from the actuall playstation site, as above? or could the online/offline icons be added to the above code with a background image?

 

I hope i have explained the above clearly, if theirs any thing anyone is unsure of please dont hesitate to ask.

 

Hopefully someone can help. :thumb-up:

 

Thanks, Lee

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.