簡體   English   中英

linkedin:消息未發布

[英]linkedin: Message not getting posted

在提供用戶名和密碼並單擊“登錄並允許”按鈕后,我正在進行linkedin集成以在android中共享數據,因此我無法移至下一頁,而是返回上一頁,並且數據沒有貼在牆上,我嘗試了很多教程,鏈接,但找不到我的錯誤和掙扎很多,任何人都可以幫助我。 這是我的MainActivity代碼

public class MainActivity extends Activity {
public static final String CONSUMER_KEY             = "key";
public static final String CONSUMER_SECRET          = "secret";    
public static final String APP_NAME                 = "rebuix";
public static final String OAUTH_CALLBACK_SCHEME    = "x-oauthflow-linkedin";
public static final String OAUTH_CALLBACK_HOST      = "litestcalback";
public static final String OAUTH_CALLBACK_URL       = OAUTH_CALLBACK_SCHEME + "://"   +    OAUTH_CALLBACK_HOST;


LinkedInOAuthService oAuthService = LinkedInOAuthServiceFactory
        .getInstance().createLinkedInOAuthService(CONSUMER_KEY,
                CONSUMER_SECRET);
LinkedInApiClientFactory factory = LinkedInApiClientFactory
        .newInstance(CONSUMER_KEY, CONSUMER_SECRET);
LinkedInRequestToken liToken;
LinkedInApiClient client;


@SuppressLint({ "NewApi", "NewApi", "NewApi" })
Button btnLinkedin;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new   StrictMode.ThreadPolicy.Builder()
                .permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

    Button btnLinkedinMain = (Button) findViewById(R.id.btnLinkedin);
    btnLinkedinMain.setOnClickListener(new View.OnClickListener() {



public void onClick(View v) {

    if (v.getId() == R.id.btnLinkedin) {

        oAuthService = LinkedInOAuthServiceFactory.getInstance()
                .createLinkedInOAuthService(Constants.CONSUMER_KEY,
                        Constants.CONSUMER_SECRET);
        System.out.println("oAuthService : " + oAuthService);

        factory = LinkedInApiClientFactory.newInstance(
                Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);

        liToken = oAuthService
                .getOAuthRequestToken(Constants.OAUTH_CALLBACK_URL);

        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(liToken
                .getAuthorizationUrl()));

        i.putExtra( "sms_body", false );
        try
        { 
                       startActivity(i);
    } catch (ActivityNotFoundException e) {
        // Display some sort of error message here.
    }
    }
}

protected void onNewIntent(Intent intent) {


    try {
        linkedInImport(intent);
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
}

private void linkedInImport(Intent intent) {
    String verifier = intent.getData().getQueryParameter("oauth_verifier");
    System.out.println("liToken " + liToken);
    System.out.println("verifier " + verifier);

    LinkedInAccessToken accessToken = oAuthService.getOAuthAccessToken(
            liToken, verifier);
    client = factory.createLinkedInApiClient(accessToken);

    // client.postNetworkUpdate("LinkedIn Android app test");

    Person profile = client.getProfileForCurrentUser(EnumSet.of(
            ProfileField.ID, ProfileField.FIRST_NAME,
            ProfileField.LAST_NAME, ProfileField.HEADLINE));

    System.out.println("First Name :: " + profile.getFirstName());
    System.out.println("Last Name :: " + profile.getLastName());
    System.out.println("Head Line :: " + profile.getHeadline());

};

    });
}
    }

試用本教程...您將在本教程中獲得消息發布功能..要在您的應用中進行逐步集成,請參閱此鏈接... http://code.google.com/p/socialauth-android/wiki / Linkedin

https://github.com/srivastavavivek1987/LinkedIn-Connection-in-Android

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM