JS API atributtes

Hi,
I am developing a FB App that enables automatic sign-up to a Matrix user group.

At this stage my goal is to create a 'simple_edit_user' using JS API.

Has anyone attempted creating a user with JavaScript API?

So far I have the following code for creating a comment asset working fine:


    $(document).ready(function() {
    	
    	// Set our key
    	setApiKey(3165365342);
    	
    	// Click Fn
    $('#create_user').click(function() {
    
      createAsset (245789, 'comment', 'comment name', 1, '', 1, 0, 0, 1, '"comment":" comment goes here"')
    
    });//end click
    
    });


Since the simple_edit_user asset requires both 'username' and 'password' attributes (+ the password has to be repeated twice),
the question is how do you go about it? What is the syntax for setting more than one attribute and how to set the password attribute correctly?
Help would be much appreciated

Wojtek.

[quote]
Hi,

I am developing a FB App that enables automatic sign-up to a Matrix user group.

At this stage my goal is to create a 'simple_edit_user' using JS API.

Has anyone attempted creating a user with JavaScript API?

So far I have the following code for creating a comment asset working fine:


    $(document).ready(function() {
    	
    	// Set our key
    	setApiKey(3165365342);
    	
    	// Click Fn
    $('#create_user').click(function() {
    
      createAsset (245789, 'comment', 'comment name', 1, '', 1, 0, 0, 1, '"comment":" comment goes here"')
    
    });//end click
    
    });


Since the simple_edit_user asset requires both 'username' and 'password' attributes (+ the password has to be repeated twice),
the question is how do you go about it? What is the syntax for setting more than one attribute and how to set the password attribute correctly?
Help would be much appreciated

Wojtek.
[/quote]

Hi Wojtek,
The extra attribute argument in the createAsset() function of the API is the trick here. The attribute and their values are to be passed in as the query string here. So lets say if you want the username to be 'simple_edit_user' and password to be 'abc1234' then the argument that can be passed in is 'username=simple_edit_user&password=abc1234'. Make sure to let the API create the Simple_Edit_User type assets ;)
The other attributes you might want to pass in so the asset is created perfectly are 'first_name', 'last_name' & 'email'.

Example of the createAsset call to create a simple edit user is as below :
createAsset (418, 'simple_edit_user', 'Simple Edit User', 1, '', 1, 0, 0, 1, 'username=simple_edit_user&password=abc1234&email=xyz@squiz.com.au')


Hope this helps.

Ash

Hi Ashish,


Works perfectly. Thank you very much for your help! Being able to create a user without submitting a form solves many problems.



Will definitly do some more work with the API.



Cheers.

Wojtek.

[quote]
Hi Ashish,



Works perfectly. Thank you very much for your help! Being able to create a user without submitting a form solves many problems.



Will definitly do some more work with the API.



Cheers.

Wojtek.

[/quote]





Yay!

API surely does make a lot easier for people familiar with Matrix and who wants to implement their own stuff. That is why we keep on adding new goodies to the gift bag called JS API :wink:



Cheers,



Ash