I can't seem to use the opensocial-java-client to access my data on MySpace.
I want to write a server-side application that can log in with my credentials ( MySpace username + password ) and get back (for the sake of simplicity, lets say) a list of my friends.
I'd rather not have to put the application onto my profile, but if that's a requirement, I can live with it.
I only want to use JavaEE (or Java SE) on my server - I'd rather not have to use Javascript etc.
If anyone can help me with a simple app to do this that would be fantastic!
=============================================================
The rest of this post will outline the steps I've already tried so far!
* Created a MySpace user and got Developer status!
* Created an 'On-Site App' (called'ODP_App_Test' ) ( Can't be 100% sure settings in here are correct )
* Created a "MySpaceID App' (called 'ODP_ID_Test' ) ( Can't be 100% sure settings in here are correct )
* Added `'ODP_App_Test' to my profile, and gave it permission to view everything.
* Created a simple Java Application with the following code:
//Using latest OpenSocial code from their SVN, downloaded on 30 March '09
import org.opensocial.client.OpenSocialClient;
import org.opensocial.client.OpenSocialProvider;
public class MySpaceTest
{
private final SecuritySettings ODP_ID_Test = new SecuritySettings( "http://www.myspace.com/ODP_ID_Test", /*OAuth Consumer Secret for this App*/);
private final SecuritySettings ODP_App_Test = new SecuritySettings( "http://www.myspace.com/ODP_ID_Test", /*OAuth Consumer Secret App*/);
SecuritySettings currentSecurity = ODP_ID_Test;
// SecuritySettings currentSecurity = ODP_App_Test;
String viewerId = "462720088";
public static void main( String[ args )
{
new MySpaceTest();
}
MySpaceTest()
{
OpenSocialClient c = new OpenSocialClient( OpenSocialProvider.MYSPACE );
c.setProperty( OpenSocialClient.Property.DEBUG, "true" );
c.setProperty( OpenSocialClient.Property.CONSUMER_KEY, currentSecurity.publicKey );
c.setProperty( OpenSocialClient.Property.CONSUMER_SECRET, currentSecurity.privateKey );
c.setProperty( OpenSocialClient.Property.VIEWER_ID, viewerId );
try
{
c.fetchPerson();
}
catch( Exception e )
{
e.printStackTrace();
}
}
private class SecuritySettings
{
String publicKey;
String privateKey;
String gadgetUri;
SecuritySettings( String publicKey, String privateKey )
{
this.publicKey = publicKey;
this.privateKey = privateKey;
}
}
}
Running this gives me the following error: (Running using ODP_App_Test credentials gives me more or less the same error)
Open Social Test App.
Signature base string:
GET&http%3A%2F%2Fapi.myspace.com%2Fv2%2Fpeople%2F%40me%2F%40self&oauth_consumer_key%3Dhttp%253A%252F%252Fwww.myspace.com%252FODP_ID_Test%26oauth_nonce%3D4412770727519%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1238492396%26oauth_token%3D%26oauth_version%3D1.0%26xoauth_requestor_id%3D462720088
Request URL:
http://api.myspace.com/v2/people/@me/@self?oauth_signature=DKmpEsJlgt%2BpawaO1OGckLEU9hw%3D&oauth_version=1.0&oauth_nonce=4412770727519&oauth_signature_method=HMAC-SHA1&oauth_consumer_key=http%3A%2F%2Fwww.myspace.com%2FODP_ID_Test&oauth_token=&xoauth_requestor_id=462720088&oauth_timestamp=1238492396
Request body:
null
Container response:
null
java.lang.NullPointerException
at org.opensocial.client.OpenSocialClient.fetchPerson(OpenSocialClient.java:131)
at org.opensocial.client.OpenSocialClient.fetchPerson(OpenSocialClient.java:124)
at org.opensocial.client.OpenSocialClient.fetchPerson(OpenSocialClient.java:102)
at com.cibenix.magellan.widgetdemo.socialnetworks.opensocial.Test.myspaceAttempt(Test.java:62)
at com.cibenix.magellan.widgetdemo.socialnetworks.opensocial.Test.<init>(Test.java:45)
at com.cibenix.magellan.widgetdemo.socialnetworks.opensocial.Test.main(Test.java:32)