开发者

easy facebook android sdk library

开发者 https://www.devze.com 2023-02-27 01:21 出处:网络
i want connect my android application to facebook , I have downloaded easy facebook android sdk , and imported the jar into my project. Can someone help me to configure the parameters of my facebook a

i want connect my android application to facebook , I have downloaded easy facebook android sdk , and imported the jar into my project. Can someone help me to configure the parameters of my facebook application?

public class FacebookConnect extends Activity implements LoginListener {

        private FBLoginManager fbManager;

        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                shareFacebook();
        }

        public void shareFacebook() {

                //change the permissions according to the function you want to use 
                String permissions[] = { "user_relationship_details",
                                        "user_religion_politics",
                                        "user_work_history",
                                        "user_relationships",
                                        "user_interests",
                                        "user_likes",
                                        "user_location",
                                        "user_hometown",
                                        "user_education_history",
                                        "user_activities",
                                        "read_stream",
                                        "offline_access"};

                //change the parameters with those of your application
                fbManager = new FBLoginManager(this, "FacebookApplicationName",
                "FacebookApplicationAPIKEY","FacebookApplicationSECRETKEY",
                "FacebookApplicationID","FacebookApplicationSite",permissions);



                if (fbManager.existsSavedFacebook()) 
                   fbManager.loadFacebook(R.layout.b开发者_运维问答lack);
                else 
                   fbManager.login(R.layout.black);

        }

        public void onLoginFail() {
                fbManager.displayToast("Login failed!");

        }

        public void onLoginSuccess(Facebook facebook) {

                //library use example
                GraphApi graphApi= new GraphApi(facebook);
                User myFacebookAccount = graphApi.getMyAccountInfo();

        }
}


I would start by filling up the fields of the FBLoginManager constructor with the relevant information:

public FBLoginManager(Activity activity,
                      java.lang.String appName,
                      java.lang.String apiKey,
                      java.lang.String secretKey,
                      java.lang.String appID,
                      java.lang.String site,
                      java.lang.String[] permission)

The instructions on how to fill them up are clearly stated here: http://www.easyfacebookandroidsdk.com/guide.asp

I would recommend you also to read the facebook getting started guide here: http://developers.facebook.com/docs/
to have a general idea of a fb app, and the android specific guide:
http://developers.facebook.com/docs/guides/mobile/#android
to understand how to create the key hash


You must to register on facebook site to use this SDK (actually - to send request and obtain the data from this site)

This tool generates a string that must be registered in the Mobile & Devices section of the Developer App for your app:

http://developers.facebook.com/docs/guides/mobile/

0

精彩评论

暂无评论...
验证码 换一张
取 消