python - 使用 Facebook Python Business SDK 使用 remote_create 时出现 TypeError
问题描述
尝试在 Facebook Python Business SDK 中运行 remote_create 方法时,我目前收到此错误(以及最近的调用):
Traceback (most recent call last):
File "ad_creator.py", line 41, in <module>
campaign.remote_create()
File "/usr/local/lib/python3.6/site-packages/facebook_business/adobjects/abstractcrudobject.py", line 296, in remote_create
response = request.execute()
File "/usr/local/lib/python3.6/site-packages/facebook_business/api.py", line 667, in execute
api_version=self._api_version,
File "/usr/local/lib/python3.6/site-packages/facebook_business/api.py", line 329, in call
if fb_response.is_failure():
File "/usr/local/lib/python3.6/site-packages/facebook_business/api.py", line 117, in is_failure
return not self.is_success()
File "/usr/local/lib/python3.6/site-packages/facebook_business/api.py", line 102, in is_success
return json_body['success']
TypeError: string indices must be integers
看来错误是从 API 中的 api.py 文件引发的: https ://github.com/facebook/facebook-python-business-sdk/blob/master/facebook_business/api.py
我的代码(创建 Facebook 会话后)如下:
if __name__ == '__main__':
FacebookAdsApi.set_default_api(api)
account = AdAccount(config['act_id'])
print('**** Creating ad...')
campaign = Campaign(parent_id=account)
campaign.update({
Campaign.Field.name: 'My First Campaign',
Campaign.Field.objective: 'REACH',
})
campaign.remote_create()
print(campaign)
请帮助我找出导致 TypeError 的原因。
解决方案
推荐阅读
- pandas - 对应列之间的求和积 - Pandas / Numpy
- angular - Angular 8中的水平滚动事件?
- reactjs - 使用 React Router Dom 将用户传递给类
- regex - 获得第二组的一部分
- javascript - 我想在 reactjs 中将对象转换为整数类型
- c++ - 操作系统如何检测进程崩溃
- sql - Sql - 如何根据来自 mssql 的列生成唯一记录
- java - 从 Java 客户端向我的 Whatsapp 发送消息
- python - 如何使用 Loader 将 pandas DataFrame 对象加载为单独的表?
- angular - 角度 - 自定义纯管道作为单例实例?