Skip to content

Instantly share code, notes, and snippets.

@derekgottlieb
Created June 5, 2016 12:36
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/6bf86a2d481c564d03a6d50f63bff0f7 to your computer and use it in GitHub Desktop.
Save derekgottlieb/6bf86a2d481c564d03a6d50f63bff0f7 to your computer and use it in GitHub Desktop.
iOS share URL to Apollo for Pythonista
# coding: utf-8
import requests
import appex
import console
group_one = "uuid-one"
group_two = "uuid-two"
group_three = "uuid-three"
def main():
if not appex.is_running_extension():
print 'This script is intended to be run from the sharing extension.'
return
url = appex.get_url()
group_index = console.alert('Apollo Room:', '', 'Room one', 'Room two', 'Room three')#, 'DevOps')
if group_index == 1:
group = group_one
if group_index == 2:
group = group_two
if group_index == 3:
group = group_three
if not url:
print 'No input URL found.'
return
print url
headers = {
'Apollo-Account': 'USER_GOES_HERE',
'Apollo-Key': 'API_KEY',
'Content-Type': 'application/json',
}
data = '{ "group": "' + group + '", "content": {"text": "' + url + '"}, "publish": true }'
r = requests.post('https://app.apollohd.com/api/messages', 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