Linkedin第三方登录集成(android)

1.需要在linkedin开发者那里注册应用。 https://www.linkedin.com/developer/apps/new
添加后,需要填写应用包名和package Hash码
Linkedin第三方登录集成(android)_第1张图片
具体方式可自行百度或者参考 http://blog.csdn.net/u010838555/article/details/39851863
2.下载linkedin的sdk,https://developer.linkedin.com/downloads#androidsdk并以module的方式集成到自己的项目中
3.获取手机端的授权 详情:https://developer.linkedin.com/docs/android-sdk-auth

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {    
        // Store a reference to the current activity 
        final Activity thisActivity = this;

        LISessionManager.getInstance(getApplicationContext()).init(thisActivity, buildScope(), new AuthListener() {
            @Override
            public void onAuthSuccess() {
                // Authentication was successful.  You can now do
                // other calls with the SDK.
            }

            @Override
            public void onAuthError(LIAuthError error) {
                // Handle authentication errors
            }
        }, true);
    }
}

// Build the list of member permissions our LinkedIn session requires
private static Scope buildScope() {
    return Scope.build(Scope.R_BASICPROFILE, Scope.W_SHARE);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Add this line to your existing onActivityResult() method
    LISessionManager.getInstance(getApplicationContext()).onActivityResult(this, requestCode, resultCode, data);
}

4.获取授权成功后,获取用户信息 url:https://api.linkedin.com/v1/people/~ 获取全部信息 https://api.linkedin.com/v1/people/~:(firstName,lastName,id,picture-url)?format=json 获取指定信息
可参考linkedin的官方文档 https://developer.linkedin.com/docs/signin-with-linkedin

String url  ="https://api.linkedin.com/v1/people/~:(firstName,lastName,id,picture-url)?format=json";
         APIHelper apiHelper = APIHelper.getInstance(getApplicationContext());
                apiHelper.getRequest(getApplicationContext(), url, new ApiListener() {
                    @Override
                    public void onApiSuccess(ApiResponse apiResponse) {
                        // Success!
                        LogUtils.e(TAG, "apiResponse" + apiResponse.toString());
                    }

                    @Override
                    public void onApiError(LIApiError liApiError) {
                        // Error making GET request!
                        LogUtils.e(TAG, " Error making GET request!");
                    }

你可能感兴趣的:(第三方登录,android,linkedin登录)