Author Topic: Social Network Integration with RPXNow  (Read 557 times)

Offline codestryke

  • Administrator
  • Level 33
  • *****
  • Posts: 589
  • Reputation: +22/-0
    • View Profile
    • eXtremeCast Games
Social Network Integration with RPXNow
« on: January 10, 2010, 03:23:48 PM »
Yesterday I was able to spare some time to actually sit down and work with RPXNow. For those of you that don't know about rpxnow it's basically a wrapper service that will allow your site to offer signing in with OpenID and other services of that nature, to learn more check out http://www.rpxnow.com

For anyone that has used any sort of payment processing system on there web site then getting rpxnow to work is very similar, the big difference is rpxnow forces you to use cURL library to support transfer via https. The handshaking between you and rpx isn't to terrible when you get it done the worst part is just deciphering the crappy quick start guide, luckily though they have forum ;)

A quick overview of how it all works... When you signup you get an API key, from there account interface you also have to tell them from what domains you will be contacting them from (nice bit of security there IMHO). They give you a bit of javascript to put on your page that will launch there sign-in window (you can also embed it as well). In that bit of javascript you have to pass them the url of your verification page.

When a visitor attempts to sign in they are taken to the service of there choice, verify there login, and then it passes them back to your verification page with a token. In that page you send RPX your API key and token to your custom sever login and they hand back information about the person signing in.

This is basically where I stopped my testing. I got it working enough where I feel pretty confident on how the system works as a whole. The next step now is integration into a game which brings up a number of questions:
* How to present my login and signup systems with theres
* How to map a player ( they offer a key mapping feature for paid accounts, but I'm not willing to pony up the cash just yet )

These questions are not hard to answer but will take some time tinkering to make the interface intuitive for the visitors.

For those interested here is the verify page I used for testing the system:
Code: [Select]
if( isset($_POST['token']) ) {
  $post_data = array('token' => $_REQUEST['token'],
                             'apiKey' => '<insert your key here>',
                             'format' => 'json'); //Set to either 'json' or 'xml'

  // make the api call using libcurl
  $curl = curl_init();
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_URL, 'https://<insert your rpxnow server name here>/api/v2/auth_info');
  curl_setopt($curl, CURLOPT_POST, true);
  curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
  curl_setopt($curl, CURLOPT_HEADER, false);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  $raw_json = curl_exec($curl);
  curl_close($curl);

  $auth_info = json_decode($raw_json, true);
  if( $auth_info['stat'] == 'ok' ) {
    $profile = $auth_info['profile'];
    echo 'Hello ' . $profile['displayName'];
  }
  else {
    die('Something failed');
  }
}

Creating online addictions, one game at a time:

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal