Commits

Shrikant Sharat Kandula committed 45102c8

JSONised posting to twitter.

Comments (0)

Files changed (1)

plugin/twitvim.vim

     " URL-encoding the special characters because URL-encoding increases the
     " string length.
     if mesglen > s:char_limit
-        call s:warnmsg("Your tweet has ".(mesglen - s:char_limit)." too many characters. It was not sent.")
+        call s:warnmsg("Your tweet has " . (mesglen - s:char_limit) . " too many characters. It was not sent.")
     elseif mesglen < 1
         call s:warnmsg("Your tweet was empty. It was not sent.")
     else
         redraw
         echo "Sending update to Twitter..."
 
-        let url = s:get_api_root()."/statuses/update.xml"
+        let url = s:get_api_root() . "/statuses/update.json"
         let parms["status"] = mesg
         let parms["source"] = "twitvim"
 
         let [error, output] = s:run_curl_oauth(url, s:ologin, s:get_proxy(), s:get_proxy_login(), parms)
 
-        if error != ''
-            let errormsg = s:xml_get_element(output, 'error')
-            call s:errormsg("Error posting your tweet: ".(errormsg != '' ? errormsg : error))
+        let response = s:parse_json(output)
+
+        if !empty(error) || has_key(response, 'error')
+            call s:errormsg("Error posting your tweet: " . (empty(error) ? response.error : error))
         else
-            call s:add_update(output)
+            call s:add_update_json(response)
             redraw
-            echo "Your tweet was sent. You used ".mesglen." characters."
+            echo "Your tweet was sent. You used " . mesglen . " characters."
         endif
     endif
 endfunction
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.