PHP卷曲的Facebook透视报告URL
问题描述:
我想见解使用CSV报告,Facebook的营销APIPHP卷曲的Facebook透视报告URL
https://developers.facebook.com/docs/marketing-api/insights/async/v2.8
出口通过发送POST请求/见解终点,我能顺利拿到AD_REPORT_RUN_ID和手动从浏览器下载报告工作正常,但当试图通过PHP curl下载报告时,我得到空的答复。
这里是我的卷曲代码: -
$fileName = "campaign_insights.csv";
$reportDownloadUrl = "https://www.facebook.com/ads/ads_insights/export_report/?report_run_id=<AD_REPORT_RUN_ID>&access_token=<ACCESS_TOKEN>&name=campaigns_insights&format=csv";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $reportDownloadUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSLVERSION,6);
$result = curl_exec($ch);
if(curl_error($ch))
{
echo 'Error Occured :' . curl_error($ch);
}
curl_close($ch);
$fp = fopen($fileName, 'w');
fwrite($fp, $result);
fclose($fp);
任何想法如何得到这个工作?
答
可以通过调用端点https://graph.facebook.com/v2.8/AD_REPORT_RUN_ID/insights
为什么会得到空响应的原因得到异步见解结果是,https://www.facebook.com/ads/ads_insights/export_report不是图形API的一部分,它使用不同的身份验证方法。它不会读取params中的access_token。
如果你print_r(json_decode($ result))是空的?他们是否也推荐您可以使用的2个SSL选项? – noelnoegdip