FacebookAds Python SDK AppID KeyError

时间:2015-10-16 09:16:11

标签: facebook python-2.7 app-id

from facebookads import FacebookSession
from facebookads import FacebookAdsApi
from facebookads.objects import (
    AdUser,
    Campaign
)

import json
import os
import pprint

pp = pprint.PrettyPrinter(indent=4)
this_dir = os.path.dirname(__file__)
config_filename = os.path.join(this_dir, 'config.json')
config_file = open(config_filename)
config = json.load(config_file)
config_file.close()

### Setup session and api objects
session = FacebookSession(
    config['XXXXXXXXXXXXXX']--This is AppId,
    config['XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX']--This is AppSecret,
    config['XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX']--This is AccessToken,
)

api = FacebookAdsApi(session)

if __name__ == '__main__':
    FacebookAdsApi.set_default_api(api)

    print('\n\n\n********** Reading objects example. **********\n')

我尝试收集facebook-ads结果cliks,页面视图等。这是我的代码部分。如果我运行此代码我有一个错误:

Traceback (most recent call last):
  File "/home/kerimcaner/PycharmProjects/facebook/deneme.py", line 23, in <module>
    config[XXXXXXXXXXXXXXXXX],
KeyError: XXXXXXXXXXXXXXXXX

我检查了很多次我的appId所以它是真的但代码不起作用。

0 个答案:

没有答案