This repository has been archived by the owner on Feb 3, 2020. It is now read-only.
forked from kneeshemoorah/facebook-android-sdk
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Luke Shepard
committed
May 19, 2010
1 parent
6de015f
commit 2cd0181
Showing
4 changed files
with
124 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
This open source Java library allows you to integrate Facebook into your Android application. | ||
|
||
Except as otherwise noted, the Facebook Connect Android SDK is licensed under the Apache Licence, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html) | ||
|
||
== Status == | ||
|
||
This is an <i>alpha</i> release. In order to guide the development of the library and allow you to freely inspect and use the source, we have open sourced the library. The underlying APIs are generally stable, however we may make changes to the library in response to developer feedback. | ||
|
||
== Getting Started == | ||
|
||
You will need the following: | ||
|
||
=== Install necessary packages === | ||
|
||
* Follow the (http://developer.android.com/sdk/index.html)[Android SDK Getting Started Guide]. | ||
|
||
* Pull this repository from github | ||
|
||
git clone git@github.com:facebook/android-sdk.git | ||
|
||
* Import the Facebook SDK project into your Eclipse workspace. | ||
* Open the __File__ menu, click on __Import...__ and choose __Existing project into workspace__ under the General group. | ||
* Select the __facebook__ subdirectory from within the git repository. | ||
* You should see an entry for __FacebookSDK__ listed under __Projects__. Click __Finish__. | ||
|
||
* To ensure Eclipse can build the project, you will have to define the ANDROID_DIR build path variable. | ||
* Right click on the project, select __Build Path->Configure Build Path...__. | ||
* In the __Java Build Path__ panel, select the __Libraries__ tab, and click __Add Variable..._. | ||
* In the popup, click on __Configure Variables...__ and then __New...__ | ||
* In the 'name' field enter __ANDROID_DIR__ and in the 'path' field click on __Folder...__ and select the directory on your computer that contains the android.jar file from the Android SDK. | ||
|
||
__NOTE: This does not work right now. You have to add the android.jar file directly__ | ||
|
||
The SDK is now configured and ready to go. | ||
|
||
=== Run the sample application === | ||
|
||
To test the SDK, you should run the simple sample application included. | ||
|
||
* Import the sample application project into your Eclipse workspace. | ||
* Import as above, but choose the __examples/simple__ subdirectory from within the git repository. | ||
* You should see an entry for FacebookSDK-example. | ||
|
||
=== Create your own application === | ||
|
||
* Create a Facebook Application: http://www.facebook.com/developers/createapp.php | ||
* Check out the mobile documentation: http://developers.facebook.com/docs/guides/mobile/ | ||
|
||
== Usage == | ||
|
||
With the Android SDK, you can do three main things: | ||
|
||
* Authorize users to your application | ||
* Make API requests | ||
* Display a Facebook dialog | ||
|
||
== Authentication and Authorization == | ||
|
||
Authorization and login use the same method. By default, if you pass no ''permissions'' parameter, then you will get access to the user's general information. | ||
This includes their name, profile picture, list of friends and other general information. For more information, see http://developers.facebook.com/docs/authentication/. | ||
|
||
If you pass in extra permissions in the permissions parameter, then you will see it. | ||
|
||
This SDK uses the (http://tools.ietf.org/html/draft-ietf-oauth-v2)["user-agent"] flow from OAuth 2.0 for authentication. | ||
|
||
To authorize a user, the simplest usage is: | ||
|
||
facebook = new Facebook(); | ||
facebook.authorize(context, applicationId, new LoginDialogListener()); | ||
|
||
See the sample applications for more specific code samples. | ||
|
||
== Logout == | ||
|
||
When the user wants to stop using Facebook integration with your application, you can offer them a "logout" link. The logout method clears local state and resets the class for use by another user. | ||
|
||
== Accessing the API == | ||
|
||
The (http://developers.facebook.com/docs/api)[Facebook Graph API] presents a simple, consistent view of the Facebook social graph, uniformly representing objects in the graph (e.g., people, photos, events, and fan pages) and the connections between them (e.g., friend relationships, shared content, and photo tags). | ||
|
||
You can access the Graph API by passing the Graph Path to the ''request'' method. For example, to access information about the logged in user, call | ||
|
||
request('/me') // get information about the currently logged in user | ||
request('/platform/posts') // get the posts made by the "platform" page | ||
request('/me/friends') // get the logged-in user's friends | ||
|
||
The request call is synchronous, meaning it will block your thread. If you want to make it non-blocking, you can initialize it in a separate thread, like so: | ||
|
||
new Thread() { | ||
@Override public void run() { | ||
try { | ||
String resp = request(graphPath, parameters, httpMethod); | ||
listener.onSuccess(resp); | ||
} catch (MalformedURLException e) { | ||
listener.onError(e.getMessage()); | ||
} catch (IOException e) { | ||
listener.onError(e.getMessage()); | ||
} | ||
} | ||
}.start(); | ||
|
||
We also offer an (http://developers.facebook.com/docs/reference/rest/)[Old REST API]. To access that, pass in a parameter bag. See the docblock for the request method for more details. | ||
|
||
== User interaction with Facebook == | ||
|
||
Facebook allows user interaction for various purposes, including: | ||
|
||
* Publish to the user's stream | ||
* Share a story with a friend | ||
|
||
To do this, use the ''dialog'' method. For example: | ||
|
||
facebook.dialog(this, "stream.publish", new SampleDialogListener()) | ||
|
||
|
||
=== Error Handling === | ||
|
||
For synchronous methods (request), errors are thrown by exception. For the asynchronous methods (dialog, authorize), errors are passed to the onException method of the listener class. | ||
|
||
Make sure to handle errors appropriately to give your users a good experience. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="lib" path="/Users/ssoneff/Downloads/android-sdk-mac_86/platforms/android-3/android.jar"/> | ||
<classpathentry kind="var" path="ANDROID_DIR"/> | ||
<classpathentry kind="lib" path="/Users/lshepard/Code/android/android-sdk-mac_86/platforms/android-7/android.jar"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |