Now we move to the implementation on our site, which is the most complicated part. The key are to use the access Oauth protocol, which consists of 3 steps:
- Our site ask for the access token (request_token) MySpace returns the password (token)
- Generates the key “signature”. This signature will expire in a period of time defined by MS (about 5 minutes). With it you can have the link to put on your site. You also set a callback which will be redirected after logging.
- We made the calls to the MySpace API. Just simply modify the line $user=’https://api.myspace.com/v1/user’; of the example and call up the URL of the form described in https://developer.myspace.com/community/RestfulAPIs/resources.aspx. Keep in mind that we must generate a signature key for each callback URL.
Conclusions (at time of writing this article):
- MySpace is a very new tool, which is constantly being modified, for example while doing a project using this tool, we had to encode it again because MySpace had amended its framework with which build this applications. This can play against in the development of MySpace app, which is still very unstable.
- Other against: is not even supported the invitation to contacts on MySpace from other sites (you can do it with facebook now)
MySpace objMS $ = new ($ oauth_consumer, $ _oauth_secret)
Where the parameters are the data of our application of MySpace.
getLinkToUser function ($ callback) / / creates the link for the user to log in callback is the address where we introduced q then log back on MySpace.
** After user log, can be used:
getMySpaceID function () / / returns the ID of the user logged getMySpaceProfile function ($ id_myspace) / / returns the id of the user profile from MySpace getMySpaceFriends function ($ id_myspace) / / returns the list of friends of the MySpace user ID