Yahoo gemini报告API错误

时间:2016-11-22 15:36:06

标签: php yahoo yahoo-api

我尝试使用Reporting API https://developer.yahoo.com/gemini/guide/reporting/cubes/#performance-stats

但是当我尝试请求URI来创建报告时 - 我收到带有消息的响应400

{"errors":[{"errIndex":-1,"code":"E40000_INVALID_INPUT","message":"Entity (publisher or advertiser id) not available","description":""}],"response":null,"timestamp":"2016-11-22 15:25:24"}

将数据传递给api端点:

$data = [
    'cube' => 'performance_stats',
    'fields' => [
        ['field'=> 'Ad ID'],
        ['field'=> 'Advertiser ID'],
        ['field'=> 'Day'],
        ['field'=> 'Spend'],
    ],
    'filters' => [
        ['field' => 'Advertiser ID', 'operator' => '=', 'value' => xxxxx],
        ['field' => 'Campaign ID', 'operator' => 'IN', 'values' => [xxxxx]],
        ['field' => 'Day', 'operator' => 'between', 'from' => '2016-11-20', 'to' => '2016-11-21'],
    ]
];

似乎没问题,大多是从文档中复制的。

过滤器中使用的广告商存在。我也可以通过网址https://api.gemini.yahoo.com/v2/rest/advertiser/xxxxx,广告系列来申请。

我发现很少有论坛讨论,但他们并没有真正帮助:

1。https://forums.developer.yahoo.net/discussion/7009/gemini-reporting-help

2。https://forums.developer.yahoo.net/discussion/7091/gemini-reports-api-no-longer-working-as-expected

3。https://forums.developer.yahoo.net/discussion/7347/yahoo-gemini-custom-reporting

有人面对这样的问题吗?

2 个答案:

答案 0 :(得分:1)

以下是解决方案: -

    $access_token = "YOUR_ACCESS_TOKEN";
    $headers = array('Authorization: Bearer ' . $access_token, 'Accept: application/json', 'Content-Type: application/json');
    $postdata = [
    'cube' => 'performance_stats',
    'fields' => [
        ['field'=> 'Ad ID'],
        ['field'=> 'Advertiser ID'],
        ['field'=> 'Day'],
        ['field'=> 'Spend'],
    ],
    'filters' => [
        ['field' => 'Advertiser ID', 'operator' => '=', 'value' => xxxxx],
        ['field' => 'Campaign ID', 'operator' => 'IN', 'values' => [xxxxx]],
        ['field' => 'Day', 'operator' => 'between', 'from' => '2016-11-20', 'to' => '2016-11-21'],
    ]
];
    $curl = curl_init("https://api.gemini.yahoo.com/v2/rest/reports/custom/");
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($postdata));
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($curl);

在此处阅读文档https://developer.yahoo.com/gemini/guide/reporting/

答案 1 :(得分:0)

根据该文档,答案是:每个报告请求都需要“广告商ID”和“日期”过滤器。