initial facebook posting stuff

workspace
Brendan Howell 8 years ago
parent 546f449706
commit d13ad2f873

@ -1,3 +1,5 @@
import facebook
import requests
import twitter
from bureau import Bureau, add_command, add_api
@ -40,6 +42,33 @@ class PublicRelations(Bureau):
id_img1 = t_up.media.upload(media=imagedata)["media_id_string"]
self.t.t.statuses.update(status="#screenless", media_ids=id_img1)
@add_command("fbpost", "Post to Facebook")
def post_fb(self):
"""
Takes a photograph using the document camera and posts it to Facebook.
"""
photo = self.send("PX", "photo")["photo"]
access_token = 'EAADixisn70ABADh2rEMZAYA8nGzd6ah8RFZA3URba263aCQ63ajLeTiZC5sgZCyIVSmRZBWReVsO9IuaLibX5RjW9Ja2tTZAbxgrDr1dPJzyGwcGTSV9bW1W4NigN0d9dFIH35W2fZBOkhvuLqOCDCBacIPjXPMxF7DRGyrz5lVHxTc04OlBeRX'
page_id = "screenless"
graph = facebook.GraphAPI(access_token)
#graph.put_object(parent_object=page_id, connection_name='feed',
# message='testing screenless post')
print("uploading photo " + photo)
graph.put_photo(image=open(photo, 'rb'), album_path=page_id + "/photos",
message='test photo')
#files = {"file": ("cam.jpg", open(photo, 'rb'))}
#args = {}
#args["access_token"] = access_token
#args["caption"] = "test cam"
#resp = requests.post(facebook.FACEBOOK_GRAPH_URL + graph.version + "/"\
# + "me" + "/photos",
# files=files,
# params=args,
# timeout=graph.timeout,
# proxies=graph.proxies)
#print(resp.json())
@add_command("twtimeline", "Print Recent Tweets")
def tw_timeline(self, data=None):
"""

Loading…
Cancel
Save