Skip to content

Instantly share code, notes, and snippets.

@derekgottlieb
Last active August 31, 2016 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derekgottlieb/a077355a4c355301577df93ee9f413f9 to your computer and use it in GitHub Desktop.
Save derekgottlieb/a077355a4c355301577df93ee9f413f9 to your computer and use it in GitHub Desktop.
iOS share to linkdump API
# coding: utf-8
import requests
import appex
import console
import dialogs
def main():
linkdump_url = 'http://linkdump.example.com'
if not appex.is_running_extension():
print('This script is intended to be run from the sharing extension.')
return
url = appex.get_url()
tags = dialogs.input_alert('Tags:', '')
if not url:
print('No input URL found.')
return
print(url)
headers = {
'Content-Type': 'application/json',
}
data = '{' +\
'"url": "' + url + '",' +\
'"tags": "' + tags + '"' +\
'}'
r = requests.post(linkdump_url + '/api/links', headers=headers, data=data)
print(r.status_code)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment