简体   繁体   English

ios快速发布图像到linkedin

[英]ios swift post image to linkedin

I am using Swift 3 and the LinkedIn APIs to post an image to LinkedIn. 我正在使用Swift 3和LinkedIn API将图像发布到LinkedIn。

The code works when I post an image via an http URL. 当我通过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. 但是,当我使用包含iPhone上本地文件路径的URL,NSURL或String时,不会传输图像。

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": 这是我用于“ submitted-image-url”的值:

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

    • THIS WORKED - referencing a URL on the web 此工作-在网络上引用URL
  2. "/private/var/mobile/Containers/Data/Application/9BFF81E8-DFE4-41EF-B25C-A82C79CF1708/tmp/yellopost.jpeg" “/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 将其用作字符串会将除图像之外的所有数据发布到LinkedIn
  3. "file:///private/var/mobile/Containers/Data/Application/9BFF81E8-DFE4-41EF-B25C-A82C79CF1708/tmp/yellopost.jpeg" “文件:///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 “ / private / var / mobile /容器/数据/应用程序/9BFF81E8-DFE4-41EF-B25C-A82C79CF1708/tmp/yellopost.jpeg”作为NSURL

    • This fails 这失败了

So, how do I reference an image stored on the iPhone? 那么,如何参考iPhone上存储的图像?

Thanks in advance. 提前致谢。

The API only accepts remote URLs. 该API仅接受远程URL。 How will the backend access the image otherwise ? 否则后端将如何访问映像?

Eg: 例如:

{
  "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"
  }  
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM