Share on Linkedin using the SDK for iOS doesn't work

喜夏-厌秋 提交于 2019-12-20 03:10:49

问题


I'm using the mobile SDK for iOS (Version:1.0.7) to share something on LinkedIn. I can get the current account information, but when I try to share on LinkedIn,it always feedback the error description. This is my code:

let url:String = "https://api.linkedin.com/v1/people/~/shares"
let payload:String = "{\"comment\":\"Check out developer.linkedin.com! http://linkd.in/1FC2PyG\",\"visibility\":{\"code\":\"anyone\"}}"
if LISDKSessionManager.hasValidSession(){
    LISDKAPIHelper.sharedInstance().postRequest(url, stringBody: payload, success: { (response) -> Void in
          print("\(response.data)")
          }, error: { (apiError) -> Void in
          print("\(apiError.description)")
     })

Has anyone ever facing the same issue. Please help me,thanks a lot!


回答1:


This works in Swift:-

        if LISDKSessionManager.hasValidSession() {

        LISDKAPIHelper.sharedInstance().postRequest(url, stringBody: payload, success: {
            response in
            //Do something with the response
            print("\(response.data)")

            }, error: {
                error in
                //Do something with the error
                print("\(error.description)")
        })
    }



回答2:


I had the same problem when I didn't set the correct permissions.

Make sure create session with share permissions.

let permissions = [LISDK_BASIC_PROFILE_PERMISSION, LISDK_W_SHARE_PERMISSION]
LISDKSessionManager.createSession(withAuth: permissions, state: nil, showGoToAppStoreDialog: true, successBlock: ...


来源:https://stackoverflow.com/questions/36260516/share-on-linkedin-using-the-sdk-for-ios-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!