gpt4 book ai didi

php - 如何 curl Facebook 广告报告

转载 作者:可可西里 更新时间:2023-11-01 12:17:20 24 4
gpt4 key购买 nike

我想使用 CURL 将 Facebook 广告报告下载到我的服务器上,因为遗憾的是我无法访问他们的广告 API,而且可能永远也无法访问。

我使用 CURL 成功登录到 Facebook(我收到一封来自 Facebook 的电子邮件,说我的帐户已从其他地方登录,所以宾果游戏)

我用于 Facebook 登录的代码:http://www.daniweb.com/web-development/php/code/290893/facebook-login-with-curl

但是下载报告的代码不起作用。 CSV 只显示空白(因为它是服务器上的默认值)

有什么想法吗?您可以看到 Facebook CSV 文件的 URL 不是直接的,所以这可能是问题的一部分......或者 Facebook 登录代码中的 $cookie 可能是什么?

$local_file = "letsbonus-ticket.csv";//This is the file where we save the information
$remote_file = "http://www.facebook.com/ads/manage/download_report.php?act=44309118&report_run_id=6016464099986&format=csv&source=email"; //Here is the file we are downloading


$ch = curl_init();
$fp = fopen ($local_file, 'w+');
$ch = curl_init($remote_file);
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_exec($ch);
curl_close($ch);
fclose($fp);

最佳答案

只是想说明这等同于 Facebook TOS 方面的抓取。

幸运的是,您不需要与系统作对并摆弄 cookie。

Facebook Ads API 访问权限已授予所有开发者在一个层级。

参见 https://developers.facebook.com/docs/reference/ads-api/access

您目前应该可以访问开发级别

The development access level is designed for development purposes and is ideal for people who are just starting to build out their tool. In this level, you would not yet have customers using your tool. This level is open to all developers, and is intended to build out end-to-end workflows on the API before you get full permissions.

You will be able to use the API on behalf of developers or admins of your app, and you can access up to 5 ad accounts for which those users are admins. To set up the ad account list, refer to the instructions below. Please note that some API calls won't be possible with Development or Basic access because they're potentially associated with multiple accounts, or the affected account can't be identified programmatically.

因此,使用您控制的任何应用程序以及您拥有的任何广告帐户,同时授予您自己 ads_read 和/或 ads_management 权限(取决于您的需要)进行 API 调用到

/me/adaccounts 从那里你应该能够获得广告帐户信息,在你的情况下你可以调用 /act_44309118 或例如/act_44309118/stats

参见 https://developers.facebook.com/docs/reference/ads-api/overview获取所有可用内容的完整列表。

关于php - 如何 curl Facebook 广告报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23025577/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com