2017-08-17 252 views
1

我想通过我的应用程序共享URL,图像和文本到linkedin。但它显示为错误LISDkerrorAPIDomain错误403

该操作无法完成。 (LISDKErrorAPIDomain错误403)

我的代码是

func didLinkedinBtnPressed(cellObject: MyModel) { 

     let tmp = ["comment": cellObject.strSocialText!, 
        "content": ["title":"AppName", "description":cellObject.strSocialText!,"submitted-url":cellObject.strWebSite!,"submitted-image-url":cellObject.strImageUrl!],"visibility": ["code": "anyone"]] as [String : Any] 
     print("PostDtaa = \(tmp)") 
     let postData = try? JSONSerialization.data(withJSONObject: tmp, options: .prettyPrinted) 

     let url = NSString(string:"https://api.linkedin.com/v1/people/~/shares?format=json") 

     let permissions: [AnyObject] = [LISDK_BASIC_PROFILE_PERMISSION as AnyObject, LISDK_EMAILADDRESS_PERMISSION as AnyObject,LISDK_W_SHARE_PERMISSION as AnyObject] 

     LISDKSessionManager.createSession(withAuth: permissions, state: nil, showGoToAppStoreDialog: true, successBlock: { (success) ->() in 
      if LISDKSessionManager.hasValidSession() { 

       LISDKAPIHelper.sharedInstance().postRequest(url as String, body: postData, success: { (_ response) in 
        print(response ?? "") 
        self.simpleAlert(titleOfAlert: "Success", messageOfAlert: "Shared Successfully") 


        LISDKAPIHelper.sharedInstance().cancelCalls() 
        LISDKSessionManager.clearSession() 

       }, error: { (_errorRes) in 
        print(_errorRes?.localizedDescription ?? "No Error!!!") 



        LISDKAPIHelper.sharedInstance().cancelCalls() 
        LISDKSessionManager.clearSession() 

       }) 
      } 

     }, errorBlock: { (error) ->() in 
      print("%s", "error called!") 

      LISDKAPIHelper.sharedInstance().cancelCalls() 
      LISDKSessionManager.clearSession() 
     }) 
    } 

我为什么在这里得到一个403错误?

回答

1

我尝试在过去类似的问题它涉及到w_share许可

linkedin doc

所需权限:w_share

无论是在你的应用程序设置中设置为默认权限或请求 特别通过您的身份验证 过程中的范围参数,您将需要请求 命令中的w_share成员权限您的应用程序成功进行API调用以共享 内容。

w_share默认情况下禁用,因此它必须是明确启用 enter image description here

注:令牌可以通过应用程序缓存所以为了确保新的令牌(与更新的权限)是使用时,我强烈建议您从移动设备上卸载所有内容并重新安装。

+0

谢谢!我检查了rw_company_admin框,但没有使用它。 – Bali