开发者社区> 问答> 正文

LinkedIn 身份验证问题

我想使用 android 结合 LinkedIn。
使用的下面的代码:
screenshot
错误:
screenshot
我在网上查了说是因为在proxy下面的原因。但是我确定没有在 proxy下啊。请问是什么错误呢?

展开
收起
蛮大人123 2016-02-18 10:42:53 3150 0
1 条回答
写回答
取消 提交回答
  • 我说我不帅他们就打我,还说我虚伪

    请使用以下代码

    import android.app.Activity;
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;
    import android.widget.Toast;
    import com.google.code.linkedinapi.client.LinkedInApiClient;
    import com.google.code.linkedinapi.client.LinkedInApiClientFactory;
    import com.google.code.linkedinapi.client.oauth.LinkedInAccessToken;
    import com.google.code.linkedinapi.client.oauth.LinkedInOAuthService;
    import com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceFactory;
    import com.google.code.linkedinapi.client.oauth.LinkedInRequestToken;
    public class LITestActivity extends Activity {
        public static final String CONSUMER_KEY = "xx";
        public static final String CONSUMER_SECRET = "xx";
        private final static String APP_PNAME = "xx";
        public static final String APP_NAME = "xx;
        public static final String OAUTH_CALLBACK_SCHEME = "xx";
        public static final String OAUTH_CALLBACK_HOST = "xxx";
        public static final String OAUTH_CALLBACK_URL = OAUTH_CALLBACK_SCHEME
                + "://" + OAUTH_CALLBACK_HOST;
        final LinkedInOAuthService oAuthService = LinkedInOAuthServiceFactory
                .getInstance().createLinkedInOAuthService(CONSUMER_KEY,
                        CONSUMER_SECRET);
        final LinkedInApiClientFactory factory = LinkedInApiClientFactory
                .newInstance(CONSUMER_KEY, CONSUMER_SECRET);
        LinkedInRequestToken liToken;
        LinkedInApiClient client;
    //  TextView tv = null;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
        //  setContentView(R.layout.main);
        //  tv = (TextView) findViewById(R.id.tv);
            try
            {
            liToken = oAuthService.getOAuthRequestToken(OAUTH_CALLBACK_URL);
            Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(liToken
                    .getAuthorizationUrl()));
            startActivity(i);
            }catch (Exception e) {
                Toast.makeText(getBaseContext(), e.toString(), Toast.LENGTH_SHORT).show();
            }
        }
        @Override
        protected void onNewIntent(Intent intent) {
            String verifier = intent.getData().getQueryParameter("oauth_verifier");
            try{
            LinkedInAccessToken accessToken = oAuthService.getOAuthAccessToken(
                    liToken, verifier);
            client = factory.createLinkedInApiClient(accessToken);
            String tweet = "Download Android App " + "market://details?id=" + APP_PNAME;
            client.postNetworkUpdate(tweet);
            //Person p = client.getProfileForCurrentUser();
            //tv.setText(p.getLastName() + ", " + p.getFirstName());
        //      p.setCurrentStatus("tweet");
            }catch (Exception e) {
                Toast.makeText(getBaseContext(), e.toString(), Toast.LENGTH_SHORT).show();
            }
            finish();
        }
    }

    Libraries 支持jar包:
    linkedin-j-android.jar
    signpost-jetty6-1.2.1.1.jar
    signpost-core-1.2.1.1.jar

    2019-07-17 18:43:46
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
从身份开始的零信任基础 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载