我要在特定时间将大约20张20张左右的新库存照片上传到一个封闭的FB组。
我写了一个小的python 2.7脚本,它抓取我的用户访问令牌,创建相册,上传图片并发布一条消息,说明照片已准备就绪。
我在测试它之后昨晚就开始使用了它,一切似乎都很棒。就在那时我们开始从用户那里收到他们无法访问相册的消息。它似乎是一个权限问题,我不知道我需要做些什么来解决它。以下是有问题的代码片段:
group_id = 'ZZZZZZZZZZZZZZZ'
products = {
'Amelia' : 'Amelia Dress ~ $65 plus $3 shipping',
'Azure' : 'Azure Skirt ~ $35 plus $3 shipping',
'Cassie' : 'Cassie ~Pencil Skirt~ $35 plus $3 shipping',
'Classic' : 'Classic Tee ~ $35 plus $3 shipping',
'Irma' : 'Irma ~LuLaRoe Signature Tunic Tee~ $35 plus $3 shipping',
'Jade' : 'Jade ~Exercise Leggings~ $55 plus $3 shipping',
'Julia' : 'Julia Dress ~ $45 plus $3 shipping',
'Madison' : 'Madison Skirt ~ $46 plus $3 shipping',
'Monroe' : 'Monroe Kimono ~ $48 plus $3 shipping',
'Nicole' : 'Nicole Dress ~ $48 plus $3 shipping',
'Patrick' : 'Patrick Tee ~ $40 plus $3 shipping',
'Perfect' : 'Perfect Tee ~ $36 plus $3 shipping',
'Randy' : 'Randy Baseball Tee ~ $35 plus $3 shipping'
}
# Oauth token
graph = facebook.GraphAPI('XXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
for product in products.keys():
# Create album in group.
print '*** Working on ' + product + ' ***'
resp = graph.put_object(group_id, 'albums', name=products[product])
postdir = 'C:\\Users\\Aaron\\Dropbox\\' + product + '\\post'
for file in os.listdir(postdir):
print "Posting " + file
photo = open(os.path.join(postdir,file), 'rb')
graph.put_photo(photo, album_id=str(resp['id']))
photo.close()
graph.put_object(parent_object=group_id, connection_name='feed',
message=product + ' album is loaded! :)')