2016-01-07 92 views
1

我一直在使用LinkedIn mobile SDK成功地在我的应用LinkedIn本地应用程序。出错的内容分享到LinkedIn

我能够用我的应用程序成功登录,但问题是与共享内容。虽然我成功登录后,要在链接来分享我的内容,但它总是给我的错误响应

{ 
"errorCode": 0, 
"message": "Access to posting shares denied", 
"requestId": "MBB3L0G1KZ", 
"status": 403, 
"timestamp": 1452172936679 
} 

虽然我已经添加的所有权限LinkedIn enter image description here

我做了分享功能。

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); 

我试过一路解决,但我不能。所以请给出您的反馈或建议。提前的帮助将受到欢迎。

回答

3

最后我想通了什么我已经错过了。我的代码是

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); 
} 

所以,现在它的工作非常细!

1

当你初始化LISessionManager,你传递一组您希望它使用的连接OAuth范围的。在上面的示例代码,这通过0​​方法,你没有在你原来的问题包括发生的,所以我真的不能确切知道......但我怀疑,即使你有你的LinkedIn应用程序配置为请求w_share会员的权限,你是不是在做同样的buildScope()过程,这将胜过任何值设置为你的应用程序的配置默认值。

确保您buildScope()方法中包含了w_share成员权限的静态值,例如:

private static Scope buildScope() { 
    return Scope.build(Scope.W_SHARE); 
} 
+0

谢谢配合。但实际上昨天我已经解决了我的问题。 – Piyush