0
votes

I am using Swift 3 and the LinkedIn APIs to post an image to LinkedIn.

The code works when I post an image via an http URL. But, the image is not transferred when I use a URL, NSURL, or String that contains the path to a local file on my iPhone.

Here is the code that represents the data being passed:

let parameters: Parameters = [
  "content": [
    "title": "Title",
    "description": "Description",
    "submitted-url": "https://www.google.com",
    "submitted-image-url": --- This parameter is the problem --
  ],
  "comment": "comment",
  "visibility": [
    "code": "anyone"
  ]
]

Here are the values I have used for "submitted-image-url":

  1. "https://www.codeproject.com/KB/GDI-plus/ImageProcessing2/flip.jpg"

    • THIS WORKED - referencing a URL on the web
  2. "/private/var/mobile/Containers/Data/Application/9BFF81E8-DFE4-41EF-B25C-A82C79CF1708/tmp/yellopost.jpeg"

    • Using this as a String posts all the data to LinkedIn, except the image
  3. "file:///private/var/mobile/Containers/Data/Application/9BFF81E8-DFE4-41EF-B25C-A82C79CF1708/tmp/yellopost.jpeg"

    • This fails
  4. "/private/var/mobile/Containers/Data/Application/9BFF81E8-DFE4-41EF-B25C-A82C79CF1708/tmp/yellopost.jpeg" AS AN NSURL

    • This fails

So, how do I reference an image stored on the iPhone?

Thanks in advance.

1

1 Answers

0
votes

The API only accepts remote URLs. How will the backend access the image otherwise ?

E.g:

{
  "comment": "Check out developer.linkedin.com!",
  "content": {
    "title": "LinkedIn Developers Resources",
    "description": "Leverage LinkedIn's APIs to maximize engagement",
    "submitted-url": "https://developer.linkedin.com",  
    "submitted-image-url": "https://example.com/logo.png"
  },
  "visibility": {
    "code": "anyone"
  }  
}