Skip to content

Instantly share code, notes, and snippets.

@kitsunde
Created July 16, 2013 08:49
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 kitsunde/6006997 to your computer and use it in GitHub Desktop.
Save kitsunde/6006997 to your computer and use it in GitHub Desktop.
Disqus owner cannot close threads.
>>> PUBLIC_KEY = 'TkhL2k0lvpvb5KIiN8l0E1tcMAEguAXy8rPOheJfwkjUGdrWLZSJIr2Mv2Dnyhy1'
>>> SECRET_KEY = 'notmykey'
>>> ACCESS_TOKEN = 'alsonotmykey'
>>> disqus = DisqusAPI(SECRET_KEY, PUBLIC_KEY)
>>> disqus.users.details(access_token=ACCESS_TOKEN)
{'favicon': {'cache': 'https://securecdn.disqus.com/1373918630/images/favicon-default.png',
'permalink': 'https://disqus.com/api/forums/favicons/transformbusiness.jpg'},
'founder': '61541387',
'id': 'transformbusiness',
'language': 'en',
'name': 'Transform Business',
'settings': {'allowAnonPost': False,
'allowMedia': True,
'audienceSyncEnabled': False,
'backplaneEnabled': False,
'hasReactions': True,
'ssoRequired': False},
'url': 'http://www.transformbusiness.sg/'}
>>> pprint.pprint(disqus.users.details(access_token=ACCESS_TOKEN)[0])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 0
>>> pprint.pprint(disqus.users.details(access_token=ACCESS_TOKEN))
{'about': u'',
'avatar': {'cache': 'https://securecdn.disqus.com/uploads/users/6154/1387/avatar92.jpg?1373853311',
'isCustom': False,
'large': {'cache': 'https://securecdn.disqus.com/uploads/users/6154/1387/avatar92.jpg?1373853311',
'permalink': 'https://disqus.com/api/users/avatars/white_space.jpg'},
'permalink': 'https://disqus.com/api/users/avatars/white_space.jpg',
'small': {'cache': 'https://securecdn.disqus.com/uploads/users/6154/1387/avatar32.jpg?1373853311',
'permalink': 'https://disqus.com/api/users/avatars/white_space.jpg'}},
'connections': {'facebook': {'id': '764987588',
'name': 'Hwee En Tan',
'url': 'http://www.facebook.com/hweeentan'}},
'emailHash': '4713bb34b33f72169fa18b35fa178c06',
'id': '61541387',
'isAnonymous': False,
'isFollowedBy': False,
'isFollowing': False,
'isPrimary': True,
'isPrivate': False,
'joinedAt': '2013-07-10T01:02:57',
'location': u'',
'name': 'white_space',
'numFollowers': 0,
'numFollowing': 0,
'numLikesReceived': 0,
'numPosts': 10,
'profileUrl': 'http://disqus.com/white_space/',
'rep': 1.235445,
'reputation': 1.235445,
'url': u'',
'username': 'white_space'}
>>> disqus.users.listForums(access_token=ACCESS_TOKEN)
{'favicon': {'cache': 'https://securecdn.disqus.com/1373918630/images/favicon-default.png',
'permalink': 'https://disqus.com/api/forums/favicons/transformbusiness.jpg'},
'founder': '61541387',
'id': 'transformbusiness',
'language': 'en',
'name': 'Transform Business',
'settings': {'allowAnonPost': False,
'allowMedia': True,
'audienceSyncEnabled': False,
'backplaneEnabled': False,
'hasReactions': True,
'ssoRequired': False},
'url': 'http://www.transformbusiness.sg/'}
>>> disqus.forums.listThreads(forum='transformbusiness', access_token=ACCESS_TOKEN)[0]
{'author': '61541387',
'category': '2475656',
'createdAt': '2013-07-12T10:16:42',
'dislikes': 0,
'feed': 'http://transformbusiness.disqus.com/discussion_transform_business_41/latest.rss',
'forum': 'transformbusiness',
'id': '1493000506',
'identifiers': [],
'isClosed': False,
'isDeleted': False,
'likes': 0,
'link': 'http://www.transformbusiness.sg/event-discussion.html',
'message': u'',
'posts': 0,
'reactions': 0,
'slug': 'discussion_transform_business_41',
'title': 'Discussion - Transform Business',
'userScore': 0,
'userSubscription': False}
>>> disqus.threads.close(thread='1493000506', forum='transformbusiness', access_token=ACCESS_TOKEN))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/kitsunde/.virtualenvs/fujixerox/lib/python2.7/site-packages/disqusapi/__init__.py", line 87, in __call__
return self._request(**kwargs)
File "/Users/kitsunde/.virtualenvs/fujixerox/lib/python2.7/site-packages/disqusapi/__init__.py", line 142, in _request
raise ERROR_MAP.get(data['code'], APIError)(data['code'], data['response'])
disqusapi.APIError: 22: You do not have admin privileges on thread '1493000506'
@mitar
Copy link

mitar commented Jan 7, 2021

In my case this was because my access token did not have "Manage Forums" permission. I was using app's access token and by default it has only "Read, Write" permission. I had to change default permissions of the app first to include all permissions, and then it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment