Created
April 1, 2016 16:04
-
-
Save jwendell/b3d90177932347efafae4b1c6d7b9b08 to your computer and use it in GitHub Desktop.
getting an avatar url from github (run with 'gjs' interpreter)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Soup = imports.gi.Soup; | |
const Mainloop = imports.mainloop; | |
let _httpSession = new Soup.Session({user_agent: 'curl/7.43.0'}); | |
let url = 'https://api.github.com/users/jwendell'; | |
let message = new Soup.Message({method: 'GET', uri: new Soup.URI(url)}); | |
_httpSession.queue_message(message, function(session, message) { | |
if (message.status_code != Soup.KnownStatusCode.OK) { | |
log('Error: ' + message.status_code.toString()); | |
log('got: ' + message.response_body.data); | |
} else { | |
// log('got: ' + message.response_body.data); | |
let p = JSON.parse(message.response_body.data); | |
log('Avatar URL: ' + p.avatar_url); | |
} | |
Mainloop.quit('t'); | |
}); | |
Mainloop.run('t'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment