|
|
Solution for userID problem on imeem
Posted Apr 24, 2008 at 7:30 AM, Last Edited Apr 24, 2008 at 7:32 AM
1. User login’s problem
- When a user successfully logs in on imeem.com, the API only returns a “success” value. But we cannot retrieve the user’s info and data. - The problem is the API only returns a message, it does not return a string proving that user has logged in. - Because using API on 2 different domains, cookie and/or session to store the logged in user’s info is not possible.
2. Solution - The problem can be solved if the developers of imeem edit some API methods. I will explain here.
Step 1: User login - When a user logs in from another website (using usersLogin method), I think the API should return a “login string”, this string confirms that the user has logged in and can be used to retrieve his/her info on imeem. - To use this “login string”, in the database of imeem.com there should be a table to store it, let’s call this table the login_string table (either XML file or log file is OK). This is an example about the structure of the login_string table
Id: Auto ID strLogin: the “login string” to certify that the user has logged in and can be used to do some functionalities provided by the API userID: ID of user loginDate: login time (time and date) expire: the time that strLogin is still valid apiKey: the API key that was issued to the app developer at application creation
- When a user login on another site, we will usersLogin method and we need to add one more parameter (expire) to usersLogin method
apiKey: The api key that was issued to the app developer at application creation. version: The desired version of the API. This should be “1.0”. sig: An MD5 hash of the request as described in the App Authentication guide. username: imeem user name. password: imeem user’s password. expire: the time (in seconds) for a login to be still valid (e.g. 3600 = 1 hour) keepLoggedIn: whether you wish to keep the user logged in. Boolean (true or false).
- The data will be stored in the login_string table like this: ------------------------------------------------------------------------------ | id | strLogin | userID | loginDate | expire | apikey | ------------------------------------------------------------------------------ | 1 | any value | 37 | 1120231230 | 1120231230 | myAPI |
How to calculate expire Expire(col) = loginDate (time()) + $exipre (param)
- After a successful login, API will return a value for “login string” (for example: cf490296df1d34246d16826412db7c38). We will use strLogin to apply for other APIs.
Step 2: using strLogin - When a “login string” is returned, this string (strLogin) makes sure that the user has logged in on imeem and now we can use the functionalities of imeem. - For example, with usersGetCurrentUser method, after we have logged in on imeem by using usersLogin method, we will receive a “login string”. We will pass this to usersGetCurrentUser method, thus we need to add one more parameter (strLogin) to usersGetCurrentUser method:
apiKey: The api key that was issued to the app developer at application creation. Version: The desired version of the API. This should be “1.0”. sig: An MD5 hash of the request as described in the App Authentication guide. strLogin: the string that confirms the login
In imeem system: - Upon receiving a request from usersGetCurrentUser method, imeem system will check strLogin with the login_string table. If this string exists and still valid - between the values in expire (col) và loginDate(col), then the system will return the output of usersGetCurrentUser method. We do it similarly for other API methods.
I think doing this way can fix the issues on imeem.
|
|
|
Re: Solution for userID problem on imeem
Posted Apr 29, 2008 at 10:19 PM
Why not just use getCurrentUser() to nab the ID of the user that is currently logged in?
|
|
|
Re: Solution for userID problem on imeem
Posted Apr 30, 2008 at 10:37 PM
Why can't you just use the value of the cookies returned?
If you take the value of the two, and pass that up with every request (as a cookie), it is the same thing as adding that strLogin stuff to every call.
|
|
|
Re: Solution for userID problem on imeem
Posted May 05, 2008 at 2:54 AM
@Laughing Man: API to get ID of user (usersGetCurrentUser) have a problem so I written this solution. You can view here Ihttp://www.imeem.com/groups/zJqqiqve/forums/U2r0vmoH/NRCp8Opv/usersgetcurrentuser_error_php_script/@Todd Berman: I don't get cookies returned. If you get it, can you help me?
|
|
|
Re: Solution for userID problem on imeem
Posted May 06, 2008 at 8:44 PM
Khanh, The following documentation shows the names of the cookies that you should get back with every request. http://www.imeem.com/developers/documentation/ws/wsoverview/wsuserauthThe specifics for accessing these cookies will depend on the language you are using to develop your application. Sachin
|