Jump to content


Parsing user data


  • Please log in to reply
3 replies to this topic

#1 Alex

Alex

    Needs Hobby

  • IPS Staff
  • 4,454 posts

Posted 30 November 2008 - 10:40 AM

Creating a few converge applications, and everything is working brilliantly. All the handshakes are done, and everything works great. However, I'd like to know how you guys send user data across.

You've mentioned how IP.Nexus sends what licenses you have via Converge, so I guess some functionality to send additional data is there. I'd like to know how to send group information over from application a to application b, like you also do on the IPB3 preview :)

Anything information would be great xD
Alex Hobbs
ahobbs[at]invisionpower.com | Twitter

#2 bfarber

bfarber

    RBT-KS

  • IPS Management
  • 24,886 posts

Posted 01 December 2008 - 10:10 AM

In Converge
Under admin/extensions/app_modules/ create a file called ipb.php.  Here's the basic format of the file

<?php

$METHODS = array(
	
	0 => array( 'title'	   => "This executes function getData",
				'description' => "Does something, just an example",
				'key'		 => 'getData' ),
				
	1 => array( 'title'	   => "Do something else?",
				'description' => "This will execute getOtherData",
				'key'		 => 'getOtherData' ),
				
);

Next, in the Converge ACP, you have to edit the SENDING application by going to List Applications (in the Applications tab), clicking the menu next to the app, and clicking Manage Application Extension.  The above options should be listed now.  Note that "key" relates to the function name you will later create.  Select the option you want to use for this application and save.

Sending Data (sending application)

In IPB's converge_local/apis/server_functions.php you can see this code

		if ( $this->__authenticate( $auth_key, $product_id ) !== FALSE )
		{
			//-----------------------------------------
			// Grab local extension file
			//-----------------------------------------
			
			require_once( ROOT_PATH  . 'converge_local/apis/local_extension.php' );
			$extension = new local_extension( $this->ipsclass );
			
			if ( is_callable( array( $extension, $getdata_key ) ) )
			{
				$data = @call_user_func( array( $extension, $getdata_key), $email_address );
			}
			
			$return = array( 'data' => base64_encode( serialize( $data ) ) );
			
			# return complex data
			$this->class_api_server->api_send_reply( $return );
			exit();
		}

If you create a local_extension.php file with a local_extension class, you can pass the extra data.  Create a function in this class that returns whatever data you want to pass (e.g. an array of member data, or even simply the group id if that's enough), with the function name being the "key" from step 1 above (e.g. getData and getOtherData).  The email address used to login is passed to your function.

Receiving data (receiving application)

In auth.php:

		if( $this->api_server->params['extra_data'] )
		{
			$external_data = unserialize( base64_decode( $this->api_server->params['extra_data'] ) );
		}

This is the extra data that is sent, normally as an array.  For our integration, Nexus sends the customer's active package ids over, and we have a file with an array that maps that to the permission masks they should then have, and we update their group appropriately (we run a DB query after this step to set their group, override group permission masks, and so forth based on the active package ids).  All of that would be custom code - you just need $external_data.

Brandon Farber
Developer / Senior Support

If it sounds like fun, it's not allowed on the bus!

Posted Image     Posted Image

Invision Power Services, Inc.


#3 Alex

Alex

    Needs Hobby

  • IPS Staff
  • 4,454 posts

Posted 01 December 2008 - 10:52 AM

Cheers, thats really helpful :)
Alex Hobbs
ahobbs[at]invisionpower.com | Twitter

#4 bradcapo1

bradcapo1

    IPB Newbie

  • Visitors
  • Pip
  • 1 posts

Posted 20 July 2009 - 10:41 PM

Cheers and we look forward to your Forum Favourites selections!



taux pret auto - taux pret auto differe selon la rise en compte ... calculent automatiquement le taux pour un prêt automobile donne.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users