My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for

Documentation

If you'd like to see more examples or want more information about how to use the library, please file a feature request in our issue tracker explaining what you'd like to see.

GettingStarted  
Downloading and installing the Java client library.
Featured
Updated Feb 21, 2010 by apijason...@gtempaccount.com

This client library helps you work with social network data from your web server. This document will help explain where you can obtain the files for the client library and how to use them in your own projects.

Obtaining the client library

There are two options for obtaining the files for the client library.

Obtaining the pre-packaged release

Most developers will want to use a pre-packaged release, which are typically the most stable versions of the library.

Click on the Downloads tab to download the library. There are two downloads listed: a zipped archive of the entire project including dependencies, documentation, unit tests, and samples as well as a Java Archive of the standalone library (most useful when you already have the dependencies on your system). For reference, the Java client library depends on json_simple-1.1.jar, commons-codec-1.3.jar, and oauth-20090825.jar. Additionally, junit-4.5.jar is required for compiling and running the included unit tests.

After extracting the library from the zipped archive, you will have a new opensocial-java-client directory. The source files for the library can be found in opensocial-java-client/java/src.

Obtaining the most up-to-date version from SVN

The most up-to-date version of the code is available from this project's SVN repository. Obtaining the code via SVN enables developers to get early access to fixes or features that have not yet been released in the pre-packaged version or for developers who want to contribute patches back to the project. Note that SVN releases are not guaranteed to be stable -- the code may be buggy and certain interfaces may change before the next release.

Obtain the code by using the following SVN checkout command (you will need an SVN client installed on your computer):

  svn checkout http://opensocial-java-client.googlecode.com/svn/trunk/ opensocial-java-client

What to do with the files

If you downloaded the Java Archive earlier, you won't have to worry about building the library yourself. All you need to do is add opensocial.jar and the dependencies listed above to your Classpath (or your Web application's lib directory) and you're set. If you downloaded the zipped archive, you will need to build the library first before you can use it. Fortunately, this is very easy -- just follow the instructions in the included README file. The archive will be generated in the dist directory which you can then copy (along with the dependencies in java/lib) to your project.

To be able to effectively use the library, you must add it to your Classpath. If you're running a command-line application, specify the location of the libraries via the -classpath option of the java executable. If you're instead planning to integrate these libraries into a Java-based Web application, you can place these libraries in your project's war/WEB-INF/lib directory. The Java application server typically adds any JARs in this directory to your Classpath automatically. Your application server may also have a directory setup for sharing dependencies across projects which saves you the trouble of constantly re-copying these JARs every time you create a new OpenSocial project.

Once your Classpath is set (and you've restarted your application server if applicable), you're all ready to use the library! The Java library is composed of various classes, which you have to import into your own classes/servlets. For example, before you can instantiate a new Client, import the class:

  import org.opensocial.Client;
Comment by weitzelm...@gmail.com, Dec 3, 2008

In the getting started code above, you should add the line: c.setProperty(OpenSocialClient?.Properties.TOKEN, <ST FROM GADGET>);

In the earlier version, this was shown and since you need to get this for orkut, it's helpful to have it illustrated here.

Comment by deshpand...@gmail.com, Dec 25, 2008

Hi,

How do I get a MySpace? APP_KEY? I don't have my website hosted on a DMZ yet. How do I convince them to give me an APP_KEY? :-)

Also, with this APP_KEY can I get data for any MySpace? account or only mine?

Thanks & Regards, Sudeep

Comment by fausto.g...@gmail.com, Dec 29, 2008

I've try to compile and executes examples and it's all working fine,but If I try to use my details (CONSUMER_SECRET,CONSUMER_KEY AND VIEWER_ID) continue to return an error code..."Entry not found".

what does it means ? How can I understand what's I've wrong ?

Comment by alexblea...@gmail.com, Dec 29, 2008

I've been finding the same issue: the sample files compile and run fine - I've installed and verified the sample.xml - then when I try and use my own details all I see is the "Entry not found" message. I've looked around and so far been unable to find out what I need to do to make any progress..

Comment by rasika...@gmail.com, Jan 5, 2009

Hi The sample files run very well with the Viewer ID("03067092798963641994") provided. But when i visited the profile of API_DWH it shows a different viewer ID(uid=1145791881843428341) in the URL, which is other than provided in the example. How can i relate the usenname of the viewer with the viewer ID provided in the example

Comment by fighterj...@gmail.com, Jan 8, 2009

The code throws this exception. Please help. org.opensocial.client.OpenSocialRequestException?: Request returned error code: 400

at org.opensocial.client.OpenSocialBatch?.getHttpResponse(Unknown Source) at org.opensocial.client.OpenSocialBatch?.submitRpc(Unknown Source) at org.opensocial.client.OpenSocialBatch?.send(Unknown Source) at org.opensocial.client.OpenSocialClient?.fetchPeople(Unknown Source) at org.opensocial.client.OpenSocialClient?.fetchFriends(Unknown Source) at openSocial.openSocialDemo.main(openSocialDemo.java:37)

Comment by fighterj...@gmail.com, Jan 8, 2009

line 24 of OpenSocialClient?.java says-'If you install this gadget, you can substitute your own OpenSocial? ID...'. Please let me know where and how to 'install' this gadget? Thanks.

Comment by project member apijason...@gtempaccount.com, Jan 9, 2009

deshpandesudeep2005: MySpace? gives you the consumer key and secret after you create an app profile account. You need a gadget-based app to get started. See the page below for more info.

http://developer.myspace.com/Modules/Apps/Pages/CreateAppAccount.aspx

Comment by project member apijason...@gtempaccount.com, Jan 9, 2009

fausto.gastaldin and alexbleasdale:

Please post your questions to the OpenSocial client libraries discussion forum and please indicate which container(s) you're trying to fetch data from.

Comment by project member apijason...@gtempaccount.com, Jan 9, 2009

rasika4yo:

Unfortunately, orkut does not provide a mapping function to relate the two right now. If you're looking to build an application which runs inside of orkut, you can "bootstrap" your code by sending a signed request from the container to your server. This request will include the OpenSocial? ID of the user, which is what you use in all of your requests.

See this thread for more details on this.

Comment by project member apijason...@gtempaccount.com, Jan 9, 2009

fighterjockey246:

Please post your questions to the OpenSocial client libraries forum, and please provide as much detail as possible. You can feel free to privately message me with your full source -- make sure you don't post your consumer secret in the group -- and I can try to help you debug the issue.

Also, if you do an svn update, you should get, among other things, a new build.xml file. If you rebuild the library using this, you may actually get to see line numbers instead of "(Unknown Source") which may help in tracking down this bug.

Thanks.

Comment by Innovati...@gmail.com, Apr 13, 2009

whats the difference between 2 Legged OAuth and step2(openID + OAuth? Does GAE requires a certain way of applying step2 or FriendConnect??


Sign in to add a comment
Powered by Google Project Hosting