Screaming Fist commented on a Page, JSON for MIRC  -  Jul 31, 2015

I've trying to use the Google URL shortener API: https://developers.google.com/url-shortener/v1/getting_started to shorten URL's before posting them but I cant seem to get a response back. Any and all help would be appreciated.

jsonopen -uw surl https://www.googleapis.com/urlshortener/v1/url?key=[API KEY]
jsonurlmethod surl POST
jsonurlget surl "longUrl": "http://www.google.com"
echo -a $json(surl).UrlResponse
jsonurlclose

SReject  -  Aug 01, 2015
var %data = {"longUrl":"http://www.google.com"}
JSONOpen -duw surl https://www.googleapis.com/urlshortener/v1/url?key=[API KEY]
JSONUrlMethod surl POST
JSONUrlHeader surl Content-Type: application/json
JSONUrlHeader surl Content-Length: $len(%data)
JSONUrlGet surl %data
echo -a $JSON(surl).UrlResponse
Screaming Fist  -  Aug 01, 2015

Hey thanks! That worked with one tweak:

var %data = {"longUrl":"http://www.google.com"}
JSONOpen -duw surl https://www.googleapis.com/urlshortener/v1/url?key=[API KEY]
JSONUrlMethod surl POST
JSONUrlHeader surl Content-Type: application/json
JSONUrlHeader surl Content-Length: $len(%data)
JSONUrlGet surl %data
echo -a $JSON(surl, id)

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.