我必须在android应用程序中与linkedIn集成。但我没有获得访问代码。我试了很多但没用。这是我的代码..
LISessionManager.getInstance(getApplicationContext()).init(this, buildScope(), new AuthListener() {
@Override
public void onAuthSuccess() {
Log.e("LinkedIn", "User Loged in");
Toast.makeText(getApplicationContext(), "success" + LISessionManager.getInstance(getApplicationContext()).getSession().getAccessToken().toString(), Toast.LENGTH_LONG).show();
// LISessionManager.getInstance(getApplicationContext().getSession().getAccessToken().toString(), Toast.LENGTH_LONG).show();</p>
String authToken = LISessionManager.getInstance(getApplicationContext()).getSession().getAccessToken().toString();
Log.e("LinkedIn auth token", authToken);
shareLinkedInContent();
}
@Override
public void onAuthError(LIAuthError error) {
// Handle authentication errors
Log.e("LinkedIn", error.toString());
}
}, true);
private void shareLinkedInContent() {
String url = "https://api.linkedin.com/v1/people/~/shares";
Log.e("LinkedIn", "Posted" + url);
try {
JSONObject body = new JSONObject("{" +
"\"comment\": \"Sample share\"," +
"\"visibility\": { \"code\": \"anyone\" }," +
"\"content\": { " +
"\"title\": \"Sample share\"," +
"\"description\": \"Testing the mobile SDK call wrapper!\"," +
"\"submitted-url\": \"http://www.example.com/\"," +
"\"submitted-image-url\": \"http://www.example.com/pic.jpg\"" +
"}" +
"}");
Log.e("LinkedIn", "Posted" + url);
APIHelper apiHelper = APIHelper.getInstance(getApplicationContext());
apiHelper.postRequest(this, url, body, new ApiListener() {
@Override
public void onApiSuccess(ApiResponse apiResponse) {
// Success!
Log.e("LinkedIn post success", "Posted");
}
@Override
public void onApiError(LIApiError liApiError) {
Log.e("LinkedIn post error", liApiError.getMessage());
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
我得到了像{“expiresOn”:0}这样的身份验证令牌,并且没有设置共享部分给予访问权限
我使用了here的最新LinkedId SDK。
我不知道如何解决这个问题。如果有人知道,请告诉我......