Skip to content

Instantly share code, notes, and snippets.

@datamafia
Created April 3, 2015 18:18
Show Gist options
  • Save datamafia/22ddf768369135f87938 to your computer and use it in GitHub Desktop.
Save datamafia/22ddf768369135f87938 to your computer and use it in GitHub Desktop.
Prototype for posting to multiple BufferApp profile ids
"""because the instructions were not clear to me, if I missed
something or this does not work drop a comment and I will fix.
After figuring this out I just wanted to put the solution
somewhere. Code pulled from working project."""
from __future__ import print_function
import os, urllib, url
buffer_base_url = 'https://api.bufferapp.com'
data = {
'text':message,
'client_id':'YOUR CLIENT ID',
'client_secret':'YOUR CLIENT SECRET',
# next 2 lines is the voodoo
'profile_ids[0]':'BUFFER PROFILE ID A', # a hash
'profile_ids[1]':'BUFFER PROFILE ID B', # a hash
# other stuff can go here optionally
}
url = buffer_base_url+'/1/updates/create.json?access_token=%s' \
% ACCESS_TOKEN # note: create is a post
encoded_args = urllib.urlencode(data)
try:
print (urllib2.urlopen(url, encoded_args).read())
except urllib2.HTTPError as e:
print( e.code)
print (e.read())
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment