Search code examples
iosjsonlinkedin-api

Problems with sharing via LinkedIn a link with equal sign


I've encountered an issue with LinkedIn share API. I am working on a iPhone project, testing my application on iOS 4.0, 5.0. I used this project as an example:

[https://github.com/synedra/LinkedIn-OAuth-Sample-Client][1]

I thought I am a genius after successfully implementing this API not only for sharing an update, but also with following format(like shown in [https://developer.linkedin.com/documents/share-api][1]):

<?xml version="1.0" encoding="UTF-8"?>
<share>
  <comment>83% of employers will use social media to hire: 78% LinkedIn, 55% Facebook, 45% Twitter [SF Biz Times] http://bit.ly/cCpeOD</comment>
  <content>
     <title>Survey: Social networks top hiring tool - San Francisco Business Times</title>
     <submitted-url>http://sanfrancisco.bizjournals.com/sanfrancisco/stories/2010/06/28/daily34.html</submitted-url>
     <submitted-image-url>http://images.bizjournals.com/travel/cityscapes/thumbs/sm_sanfrancisco.jpg</submitted-image-url>
  </content>
  <visibility>
     <code>anyone</code>
  </visibility>
</share>

Following advices and examples, I was preparing a JSON string that i was using. So, i got this:

{
  "visibility":
  {
        "code":"anyone"
  },
  "comment":"Asd",
  "content":
  {
        "submitted-url":"http://google.com",
        "title":"googloo",
        "submitted-image-url":"http://pikci.ru/images/img_srchttpwwwcomputerrivercomimagessamsung-chat-335-qwer.jpg"
  }
}

Well, with this data inside, it works like a charm. the update is with image, clickable title and stuff. Perfect.

Then, i tried to put a link(because i really needed in purpose of my project) with a Equal sign in it: "=", like for example we have http://www.google.md/#q=Nicolas+Steno&ct=steno12-hp&oi=ddle&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=8c5a975d815425a&biw=1920&bih=881

Well, if we use this link in submitted-url, and send it, the LinkedIn will receive it, and even will give us a response. But it WONT update to the new status! It's a huge bug for my application, because the share won't work, but more than a half of the shared links will have equal sign in it. It is the third day when i'm fighting with it. I was trying different coding functions, different "smarty-pants" moves, but failed.

If anyone has a clue about what is going on here, I will hugely appreciate it...


Solution

  • When I post this body to LinkedIn I get my status updated:

    {
        "comment": "Posting from the API using JSON", 
        "content": {
             "submitted-url": 
                  "http://www.google.md/#q=Nicolas+Steno&ct=steno12-hp&oi=ddle&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=8c5a975d815425a&biw=1920&bih=881"
         }, "visibility": {
             "code": "anyone"
         }
    }
    

    However, the link itself doesn't resolve correctly. It's likely that something about that URL is tripping up our link shortener - we're working on fixing these issues but in the meantime you could use something like the Google URL shortener URL:

    body = {"longUrl": article['articleContent']['resolvedUrl']}
    resp,content = http.request("https://www.googleapis.com/urlshortener/v1/url?key=xxx","POST",body=simplejson.dumps(body),headers={"Content-Type":"application/json"})
    googleresponse = simplejson.loads(content)
    

    ... and then share that to LinkedIn. I realize it's a suboptimal solution, but until the share function gets fixed to handle these URLs it should get you going.