Skip to content

Instantly share code, notes, and snippets.

@ThomasLeCoz
Created February 17, 2016 12:31
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 ThomasLeCoz/5890ad71bc68d0e091d5 to your computer and use it in GitHub Desktop.
Save ThomasLeCoz/5890ad71bc68d0e091d5 to your computer and use it in GitHub Desktop.
import json
auth_token_sniply = 'YOUR_AUTH_TOKEN'
campaign_id = 'YOUR_CAMPAIGN_ID'
headers = {'Authorization': 'Bearer ' + auth_token_sniply, 'Content-Type': 'application/json'}
payload = {'url': input['url'], 'campaign': campaign_id}
r = requests.post('https://snip.ly/api/v2/links/', data=json.dumps(payload), headers=headers)
r.raise_for_status()
output = [{'url': r.json()['href'], 'title': input['title'], 'excerpt': input['excerpt'], 'image': input['image']}]
return output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment