将内容分享到 LinkedIn 时出错
Error on sharing the content to LinkedIn
我已经使用 LinkedIn mobile SDK
.
成功地将 LinkedIn 本地应用程序集成到我的应用程序中
我可以使用我的应用程序成功登录,但问题在于共享内容。当我成功登录时,想将我的内容分享到 Linked in 但它总是给我错误响应
{
"errorCode": 0,
"message": "Access to posting shares denied",
"requestId": "MBB3L0G1KZ",
"status": 403,
"timestamp": 1452172936679
}
尽管我已经添加了对 LinkedIn 的所有权限
我做了分享功能
void shareImageOnLinkedIn() {
String shareJsonText = "{ \n" +
" \"comment\":\"" + "TalkingBookz" + "\"," +
" \"visibility\":{ " +
" \"code\":\"anyone\"" +
" }," +
" \"content\":{ " +
" \"title\":\"+audiobookinfo.title+\"," +
" \"description\":\"+audiobookinfo.description+\"," +
" \"submitted-url\":\"+audiobookinfo.sample_url+\"," +
" \"submitted-image-url\":\"+audiobookinfo.cover_url+\"" +
" }" +
"}";
// Call the APIHealper.getInstance method and pass the current context.
APIHelper apiHelper = APIHelper.getInstance(getApplicationContext());
// call the apiHelper.postRequest with argument(Current context,url and content)
apiHelper.postRequest(BookdetailActivity.this,
shareUrl, shareJsonText, new ApiListener() {
@Override
public void onApiSuccess(ApiResponse apiResponse) {
Log.e("Response", apiResponse.toString());
Toast.makeText(getApplicationContext(), "Shared Sucessfully", Toast.LENGTH_LONG).show();
}
@Override
public void onApiError(LIApiError error) {
Log.e("Response", error.toString());
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_LONG).show();
}
});
}
现在我在成功登录响应后调用此函数。这里,
LISessionManager.getInstance(getApplicationContext()).init(this, buildScope(), new AuthListener() {
@Override
public void onAuthSuccess() {
Log.e("Access Token :", LISessionManager.getInstance(getApplicationContext()).getSession().getAccessToken().toString());
Toast.makeText(getApplicationContext(), "success" + LISessionManager.getInstance(getApplicationContext()).getSession().getAccessToken().toString(), Toast.LENGTH_LONG).show();
shareImageOnLinkedIn();
}
@Override
public void onAuthError(LIAuthError error) {
Log.v("Error", error.toString());
Toast.makeText(getApplicationContext(), "failed " + error.toString(),
Toast.LENGTH_LONG).show();
}
}, true);
我已经尝试了所有方法来解决,但我不能。因此,请提供您的反馈或建议。将得到预先帮助。
当您初始化 LISessionManager
时,您向它传递了一组您希望它用于连接的 OAuth 范围。在上面的示例代码中,这是通过您未包含在原始问题中的 buildScope()
方法发生的,所以我不能确定...但我怀疑即使您配置了 LinkedIn 应用程序要请求 w_share
成员权限,您在 buildScope()
过程中不会做同样的事情,这将胜过您在应用配置中设置为默认值的任何值。
确保您的 buildScope() 方法包含 w_share
成员权限的静态值,例如:
private static Scope buildScope() {
return Scope.build(Scope.W_SHARE);
}
我终于明白我错过了什么。我的代码是
private static Scope buildScope() {
return Scope.build(Scope.R_BASICPROFILE, Scope.R_EMAILADDRESS);
}
所以改为
private static Scope buildScope() {
return Scope.build(Scope.R_BASICPROFILE, Scope.R_EMAILADDRESS, Scope.W_SHARE);
}
所以现在它工作得很好!!
我已经使用 LinkedIn mobile SDK
.
我可以使用我的应用程序成功登录,但问题在于共享内容。当我成功登录时,想将我的内容分享到 Linked in 但它总是给我错误响应
{
"errorCode": 0,
"message": "Access to posting shares denied",
"requestId": "MBB3L0G1KZ",
"status": 403,
"timestamp": 1452172936679
}
尽管我已经添加了对 LinkedIn 的所有权限
我做了分享功能
void shareImageOnLinkedIn() {
String shareJsonText = "{ \n" +
" \"comment\":\"" + "TalkingBookz" + "\"," +
" \"visibility\":{ " +
" \"code\":\"anyone\"" +
" }," +
" \"content\":{ " +
" \"title\":\"+audiobookinfo.title+\"," +
" \"description\":\"+audiobookinfo.description+\"," +
" \"submitted-url\":\"+audiobookinfo.sample_url+\"," +
" \"submitted-image-url\":\"+audiobookinfo.cover_url+\"" +
" }" +
"}";
// Call the APIHealper.getInstance method and pass the current context.
APIHelper apiHelper = APIHelper.getInstance(getApplicationContext());
// call the apiHelper.postRequest with argument(Current context,url and content)
apiHelper.postRequest(BookdetailActivity.this,
shareUrl, shareJsonText, new ApiListener() {
@Override
public void onApiSuccess(ApiResponse apiResponse) {
Log.e("Response", apiResponse.toString());
Toast.makeText(getApplicationContext(), "Shared Sucessfully", Toast.LENGTH_LONG).show();
}
@Override
public void onApiError(LIApiError error) {
Log.e("Response", error.toString());
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_LONG).show();
}
});
}
现在我在成功登录响应后调用此函数。这里,
LISessionManager.getInstance(getApplicationContext()).init(this, buildScope(), new AuthListener() {
@Override
public void onAuthSuccess() {
Log.e("Access Token :", LISessionManager.getInstance(getApplicationContext()).getSession().getAccessToken().toString());
Toast.makeText(getApplicationContext(), "success" + LISessionManager.getInstance(getApplicationContext()).getSession().getAccessToken().toString(), Toast.LENGTH_LONG).show();
shareImageOnLinkedIn();
}
@Override
public void onAuthError(LIAuthError error) {
Log.v("Error", error.toString());
Toast.makeText(getApplicationContext(), "failed " + error.toString(),
Toast.LENGTH_LONG).show();
}
}, true);
我已经尝试了所有方法来解决,但我不能。因此,请提供您的反馈或建议。将得到预先帮助。
当您初始化 LISessionManager
时,您向它传递了一组您希望它用于连接的 OAuth 范围。在上面的示例代码中,这是通过您未包含在原始问题中的 buildScope()
方法发生的,所以我不能确定...但我怀疑即使您配置了 LinkedIn 应用程序要请求 w_share
成员权限,您在 buildScope()
过程中不会做同样的事情,这将胜过您在应用配置中设置为默认值的任何值。
确保您的 buildScope() 方法包含 w_share
成员权限的静态值,例如:
private static Scope buildScope() {
return Scope.build(Scope.W_SHARE);
}
我终于明白我错过了什么。我的代码是
private static Scope buildScope() {
return Scope.build(Scope.R_BASICPROFILE, Scope.R_EMAILADDRESS);
}
所以改为
private static Scope buildScope() {
return Scope.build(Scope.R_BASICPROFILE, Scope.R_EMAILADDRESS, Scope.W_SHARE);
}
所以现在它工作得很好!!