使用 Python 连接 facebookads 库以从 Facebook 与 Marketing API 提取数据的问题 [英] Problem with connect facebookads library for extract data from Facebook with Marketing API using Python

查看:26
本文介绍了使用 Python 连接 facebookads 库以从 Facebook 与 Marketing API 提取数据的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取有关广告系列的信息.我从这个代码开始获取活动名称.我收到此错误:

I want to get info about ad campaign. And I start from this code to get campaign name. and I get this error :

Traceback (most recent call last):
  File "C:/Users/win7/PycharmProjects/API_Facebook/dd.py", line 2, in <module>
    from facebookads.adobjects.adaccount import AdAccount
  File "C:\Users\win7\AppData\Local\Programs\Python\Python37-32\lib\site-packages\facebookads\adobjects\adaccount.py", line 1582
    def get_insights(self, fields=None, params=None, async=False, batch=None, pending=False):
                                                         ^
SyntaxError: invalid syntax
                                                     ^

可能是什么原因?如果您愿意,可以提供代码示例如何获得有关活动的更多信息?点击此处查看图片:代码和错误

What is may be reason? and if you want, can give code examples how can I get more info about campaign? Click here to view image: code and error

推荐答案

如果您使用的是 Python 3.7,请使用 async_,而不仅仅是 async.

If you're using Python 3.7, use async_, not only async.

import os, re
path = r"path facebookads"
python_files = []

for dirpath, dirnames, filenames in os.walk(path):

for filename in filenames:
if filename.endswith(".py"):
            python_files.append(os.path.join(dirpath, filename))

for dirpath, dirnames, filenames in os.walk(path):
    for filename in filenames:
        if filename.endswith(".py"):
            python_files.append(os.path.join(dirpath, filename))

for python_file in python_files:

    with open(python_file, "r") as f:
        text = f.read()
        revised_text = re.sub("async", "async_", text)

    with open(python_file, "w") as f:
        f.write(revised_text)

这篇关于使用 Python 连接 facebookads 库以从 Facebook 与 Marketing API 提取数据的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆