我正在尝试通过我的应用向LinkedIn分享网址,图片和文字。但它显示错误
无法完成操作。 (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错误?
答案 0 :(得分:1)
我过去曾尝试过类似的问题,它与w_share权限相关
来自linkedin doc 的
所需权限:w_share
是否在您的应用设置或请求中设置为默认权限 特别是在身份验证期间通过scope参数 进程中,您需要请求w_share成员权限 命令您的应用程序成功进行API调用以进行共享 内容。
注意:令牌可以由应用程序缓存,因此为了确保使用新令牌(具有更新的权限),我强烈建议您从移动设备卸载所有内容并重新安装。< / p>