Last active
August 31, 2016 02:28
-
-
Save derekgottlieb/a077355a4c355301577df93ee9f413f9 to your computer and use it in GitHub Desktop.
iOS share to linkdump API
This file contains 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
# 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