Welcome Developers!

in

Welcome!

in

Using opensocial-java-client to access user data!

Last post 04-01-2009 4:52 AM by Cibenix. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 03-31-2009 2:49 AM

    Using opensocial-java-client to access user data!

    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)

     

  • 03-31-2009 8:07 AM In reply to

    Re: Using opensocial-java-client to access user data!

     Update: Looks like myspaceid-java-sdk ( http://code.google.com/p/myspaceid-java-sdk/ )  would be a better bet for what I need - but I still can't log in using my credentials and get back the OAuth_Token needed - perhpas it's just my lack of Http skills!

  • 03-31-2009 11:12 AM In reply to

    • Kiam
    • Top 75 Contributor
    • Joined on 02-19-2009
    • Posts 62

    Re: Using opensocial-java-client to access user data!

     When you say you "can't log in using my credentials and get back the OAuth_Token needed", are you using the sample in the MySpaceID Jav SDK?

     

    Follow us on twitter for major updates and announcements:

    http://twitter.com/MySpaceDevTeam

    Friend the MDP Profile!
    http://profile.myspace.com/index.cfm?fuseaction=user.viewProfile&friendID=295946135
  • 04-01-2009 4:52 AM In reply to

    Re: Using opensocial-java-client to access user data!

     The sample (as far as I can see) requires the user to type their uesrname & password into a web-page in step 2 of the 3 step authentication!

     

     I do NOT want to use any user-input! I want to log in programatically!

Page 1 of 1 (4 items)