Android アプリケーション用の LinkedIn 共有機能を構築しています。LinkedIn にログインできますが、その後、エミュレーターに空白の画面が表示されます。私は何を間違っていますか?
consumer_key
myとremoveを含むコードは次のconsumer_secret
とおりです。
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import oauth.signpost.OAuth;
import oauth.signpost.OAuthConsumer;
import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.EditText;
import android.widget.TextView;
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;
import com.google.code.linkedinapi.schema.Person;
import com.ndot.sample.R;
import com.ndot.sample.TestConnect;
public class LinkedinActivity extends Activity {
public static final String CONSUMER_KEY = "xxxxxxxxxxxxx";
public static final String CONSUMER_SECRET = "xxxxxxxxxx";
public static final String APP_NAME = "LITest";
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;
private static final int BOOK_SELECT = 1;
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost post = new HttpPost("https://api.linkedin.com/v1/people/~/shares");
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;
private String oauth_verifier;
@Override
public void onCreate(Bundle savedInstanceState) {
super.hionCreate(savedInstanceState);
setContentView(R.layout.post);
tv = (EditText) findViewById(R.id.postscreen);
liToken = oAuthService.getOAuthRequestToken(OAUTH_CALLBACK_URL);
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(liToken
.getAuthorizationUrl()));
Log.d("log",liToken.getAuthorizationUrl());
}
@Override
protected void onNewIntent(Intent intent) {
String verifier = intent.getData().getQueryParameter("oauth_verifier");
LinkedInAccessToken accessToken = oAuthService.getOAuthAccessToken(liToken, verifier);
client = factory.createLinkedInApiClient(accessToken);
client.postNetworkUpdate("LinkedIn Android app test");
Person p = client.getProfileForCurrentUser();
tv.setText(p.getLastName() + ", " + p.getFirstName());
LinkedInAccessToken accessToken1 = oAuthService.getOAuthAccessToken(liToken, oauth_verifier);
SharedPreferences prefs = null;
final Editor edit = prefs.edit();
edit.putString(OAuth.OAUTH_TOKEN, accessToken.getToken());
edit.putString(OAuth.OAUTH_TOKEN_SECRET, accessToken.getTokenSecret());
edit.putString("linkedin_login", "valid");
}
protected void onNewIntent1(Intent intent) {
String verifier = intent.getData().getQueryParameter("oauth_verifier"); LinkedInAccessToken accessToken = oAuthService.getOAuthAccessToken(liToken, verifier);
client = factory.createLinkedInApiClient(accessToken);
Intent t = new Intent(LinkedinActivity.this, LinkedinConstants.class);
startActivity(t);
}
}