Skip to content

Instantly share code, notes, and snippets.

@itamarhaber
Created November 21, 2015 21:14
Show Gist options
  • Save itamarhaber/9a542c62204fdee62dd3 to your computer and use it in GitHub Desktop.
Save itamarhaber/9a542c62204fdee62dd3 to your computer and use it in GitHub Desktop.
Trash Mention's alerts
import requests
import json
jt = json.dumps({'trashed': True})
url = 'https://api.mention.net/api/accounts/<account identifier>/alerts/<alert identifier>/mentions'
gh = {'Accept': 'application/json', 'Accept-Language': 'en', 'Authorization': 'Bearer <token>'}
ph = gh.copy()
ph['Content-Type'] = 'application/json'
finished = False
count = 1
while not finished:
j = requests.get(url, headers=gh).json()
# the check for finished isn't really working
finished = j['reached_history_limit']
for i in j['mentions']:
print count, i['id'], i['title'], requests.put(url + '/' + i['id'], headers=ph, data=jt)
count = count + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment