报告w / Bing Ads API& PHP客户端库“错误请求”错误

时间:2016-02-17 23:55:05

标签: php api report google-adwords client-library

我正在尝试使用PHP客户端库从我的Bing Ads帐户中提取关键字报告。我收到了“错误请求”错误,报告未下载。

我正在尝试使用Bing Ads API的第9版。

以下是错误(在脚本中间使用print_r($ e))。

SoapFault Object
(
    [message:protected] => Bad Request
    [string:Exception:private] => 
    [code:protected] => 0
    [file:protected] => /home/ubuntu/workspace/BING/PHP/Bing Ads API in PHP/v9/ReportRequests.php
    [line:protected] => 303
    [trace:Exception:private] => Array
        (
            [0] => Array
                (
                    [function] => __doRequest
                    [class] => SoapClient
                    [type] => ->
                    [args] => Array
                        (
                        [0] => 
#myaccountID#041F63U87G121059xxx@hotmail.commypasswordCsvMy Keyword Performance ReportfalseDailyTimePeriodAccountIdCampaignIdKeywordKeywordIdDeviceTypeBidMatchTypeClicksImpressionsCtrAverageCpcSpendQualityScore10#myaccountID#ClicksAscendingToday
                        [1] => https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/V9/ReportingService.svc
                        [2] => SubmitGenerateReport
                        [3] => 1
                        [4] => 0
                    )
            )
        [1] => Array
            (
                [file] => /home/ubuntu/workspace/BING/PHP/Bing Ads API in PHP/v9/ReportRequests.php
                [line] => 303
                [function] => __call
                [class] => SoapClient
                [type] => ->
                [args] => Array
                    (
                        [0] => SubmitGenerateReport
                        [1] => Array
                            (
                                [0] => BingAds\Reporting\SubmitGenerateReportRequest Object
                                    (
                                        [ReportRequest] => SoapVar Object
                                            (
                                                [enc_type] => 301
                                                [enc_value] => BingAds\Reporting\KeywordPerformanceReportRequest Object
                                                    (
                                                        [Aggregation] => Daily
                                                        [Columns] => Array
                                                            (
                                                                [0] => TimePeriod
                                                                [1] => AccountId
                                                                [2] => CampaignId
                                                                [3] => Keyword
                                                                [4] => KeywordId
                                                                [5] => DeviceType
                                                                [6] => BidMatchType
                                                                [7] => Clicks
                                                                [8] => Impressions
                                                                [9] => Ctr
                                                                [10] => AverageCpc
                                                                [11] => Spend
                                                                [12] => QualityScore
                                                            )

                                                        [Filter] => 
                                                        [MaxRows] => 10
                                                        [Scope] => BingAds\Reporting\AccountThroughAdGroupReportScope Object
                                                            (             [AccountIds] => Array
                                                                    (   [0] => #myaccountID#
                                                                    )[AdGroups] => 
                                                                [Campaigns] => 
                                                            )

                                                        [Sort] => Array
                                                            (
                                                                [0] => BingAds\Reporting\KeywordPerformanceReportSort Object
                                                                    (
                                                                        [SortColumn] => Clicks
                                                                        [SortOrder] => Ascending
                                                                    )

                                                            )

                                                        [Time] => BingAds\Reporting\ReportTime Object
                                                            (
                                                                [CustomDateRangeEnd] => 
                                                                [CustomDateRangeStart] => 
                                                                [PredefinedTime] => Today
                                                            )

                                                        [Format] => Csv
                                                        [Language] => 
                                                        [ReportName] => My Keyword Performance Report
                                                        [ReturnOnlyCompleteData] => 
                                                    )

                                                [enc_stype] => KeywordPerformanceReportRequest
                                                [enc_ns] => https://bingads.microsoft.com/Reporting/v9
                                            )

                                    )

                            )

                    )

            )

        [2] => Array
            (
                [file] => /home/ubuntu/workspace/BING/PHP/Bing Ads API in PHP/v9/ReportRequests.php
                [line] => 303
                [function] => SubmitGenerateReport
                [class] => SoapClient
                [type] => ->
                [args] => Array
                    (
                        [0] => BingAds\Reporting\SubmitGenerateReportRequest Object
                            (
                                [ReportRequest] => SoapVar Object
                                    (
                                        [enc_type] => 301
                                        [enc_value] => BingAds\Reporting\KeywordPerformanceReportRequest Object
                                            (
                                                [Aggregation] => Daily
                                                [Columns] => Array
                                                    (
                                                        [0] => TimePeriod
                                                        [1] => AccountId
                                                        [2] => CampaignId
                                                        [3] => Keyword
                                                        [4] => KeywordId
                                                        [5] => DeviceType
                                                        [6] => BidMatchType
                                                        [7] => Clicks
                                                        [8] => Impressions
                                                        [9] => Ctr
                                                        [10] => AverageCpc
                                                        [11] => Spend
                                                        [12] => QualityScore
                                                    )

                                                [Filter] => 
                                                [MaxRows] => 10
                                                [Scope] => BingAds\Reporting\AccountThroughAdGroupReportScope Object
                                                    (
                                                        [AccountIds] => Array
                                                            (
                                                                [0] => #myaccountID#
                                                            )

                                                        [AdGroups] => 
                                                        [Campaigns] => 
                                                    )

                                                [Sort] => Array
                                                    (
                                                        [0] => BingAds\Reporting\KeywordPerformanceReportSort Object
                                                            (
                                                                [SortColumn] => Clicks
                                                                [SortOrder] => Ascending
                                                            )

                                                    )

                                                [Time] => BingAds\Reporting\ReportTime Object
                                                    (
                                                        [CustomDateRangeEnd] => 
                                                        [CustomDateRangeStart] => 
                                                        [PredefinedTime] => Today
                                                    )

                                                [Format] => Csv
                                                [Language] => 
                                                [ReportName] => My Keyword Performance Report
                                                [ReturnOnlyCompleteData] => 
                                            )

                                        [enc_stype] => KeywordPerformanceReportRequest
                                        [enc_ns] => https://bingads.microsoft.com/Reporting/v9
                                    )

                            )

                    )

            )

        [3] => Array
            (
                [file] => /home/ubuntu/workspace/BING/PHP/Bing Ads API in PHP/v9/ReportRequests.php
                [line] => 103
                [function] => SubmitGenerateReport
                [args] => Array
                    (
                        [0] => BingAds\Proxy\ClientProxy Object
                            (
                                [authenticationToken:BingAds\Proxy\ClientProxy:private] => 
                                [username:BingAds\Proxy\ClientProxy:private] => xxx@hotmail.com
                                [password:BingAds\Proxy\ClientProxy:private] => mypassword
                                [developerToken:BingAds\Proxy\ClientProxy:private] => 041F63U87G121059
                                [wsdlUrl:BingAds\Proxy\ClientProxy:private] => https://api.bingads.microsoft.com/Api/Advertiser/Reporting/V9/ReportingService.svc?singleWsdl
                                [accountId:BingAds\Proxy\ClientProxy:private] => #myaccountID#
                                [customerId:BingAds\Proxy\ClientProxy:private] => 
                                [service:BingAds\Proxy\ClientProxy:private] => SoapClient Object
                                    (
                                        [trace] => 1
                                        [_features] => 1
                                        [_soap_version] => 1
                                        [sdl] => Resource id #6
                                        [typemap] => Resource id #7
                                        [__default_headers] => Array
                                            (
                                                [0] => SoapHeader Object
                                                    (
                                                        [namespace] => https://bingads.microsoft.com/Reporting/v9
                                                        [name] => #myaccountID#
                                                        [data] => #myaccountID#
                                                        [mustUnderstand] => 
                                                    )

                                                [1] => SoapHeader Object
                                                    (
                                                        [namespace] => https://bingads.microsoft.com/Reporting/v9
                                                        [name] => #mycustID#
                                                        [data] => 
                                                        [mustUnderstand] => 
                                                    )

                                                [2] => SoapHeader Object
                                                    (
                                                        [namespace] => https://bingads.microsoft.com/Reporting/v9
                                                        [name] => 041F63U87G121059
                                                        [data] => 041F63U87G121059
                                                        [mustUnderstand] => 
                                                    )

                                                [3] => SoapHeader Object
                                                    (
                                                        [namespace] => https://bingads.microsoft.com/Reporting/v9
                                                        [name] => xxx@hotmail.com
                                                        [data] => xxx@hotmail.com
                                                        [mustUnderstand] => 
                                                    )

                                                [4] => SoapHeader Object
                                                    (
                                                        [namespace] => https://bingads.microsoft.com/Reporting/v9
                                                        [name] => mypassword
                                                        [data] => mypassword
                                                        [mustUnderstand] => 
                                                    )

                                                [5] => SoapHeader Object
                                                    (
                                                        [namespace] => https://bingads.microsoft.com/Reporting/v9
                                                        [name] => EwBoAnhlBAAUxT83/QvqiAZEx5SuwyhZqHzk21oAAZOYUlCZ8fHq%2bAPC1k3PVSu8c8EXUqNZW8qb%2b52zO2/YZKkXopE7MvVZO7lWS69iMgHWTJO21LhVFN93oPs2KLl/dp7ZZBXqnf/LwqkIKys5hMpr%2b5XvExI/nywKmFbsHDcT9dyXnUCpQf4q14GGTdtQGPmTh9xsDo0sMIdoQtNovU8pk1/kWriQDLn%2bGaBnMr0RIH6h1tvjbCql2MyWhr207gqvTap8tuWnkDW75rUR6QrSCPifyC54dygFTzXKq0ggN/kMmdImOSn/8BxZ6KoUUTLVVBbxayEwrrHuh1QeuBfnh4PRMIwX7BwHUdVTyjB%2bAzJXFzOKlUD39Oyszn4DZgAACA3FE6D1xZKXOAH6f0KgK8gFEhnH7Wi3Q1LqjnocaIoY/royWIFGyGlatJQiKJK4N0XYquNcMfFwFeRX6pto6GumUm%2bhOCT/yV3%2bFdSFxvX4ZjRFP/lldQvPG4dULM%2b1uvZiegv5upygYR1r2l03zMlJ2MU28jE4F%2b34RxbNZVXxtpckAHed5YAUZgcJVjg7jK5nkShwjjqnz4iuqofn8T/KBc0hlsHBzBYVoTwNqUX2OOel3XNGQQS8a3rT1I5R2%2bQ%2bxmIxWbyAtI8hHtLIiF6tHp6fj/JkSm4Euo43ckxFpdWL%2bKAfWGZPnVkCqVXV4pZl3HbkPfaIqjCnhVHj9xn1yHhbQbStCkXmLK%2bpN9Xa0inIJgqzRFobRAtzZa1umvqe7yIbBgCobDYNsyVYCxQkkhJ9jXYbQfNG041trWNLaMBRAQ%3d%3d
                                                        [data] => 
                                                        [mustUnderstand] => 
                                                    )
                                            )
                                        [__last_request] => 
#myaccountID#041F63U87G121059xxx@hotmail.commypasswordCsvMy Keyword Performance ReportfalseDailyTimePeriodAccountIdCampaignIdKeywordKeywordIdDeviceTypeBidMatchTypeClicksImpressionsCtrAverageCpcSpendQualityScore10#myaccountID#ClicksAscendingToday

                                            [httpsocket] => Resource id #8
                                            [_use_proxy] => 0
                                            [httpurl] => Resource id #9
                                            [__last_request_headers] => POST /Api/Advertiser/Reporting/V9/ReportingService.svc HTTP/1.1
Host: reporting.api.bingads.microsoft.com
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.5.9-1ubuntu4.13
Content-Type: text/xml; charset=utf-8
SOAPAction: "SubmitGenerateReport"
Content-Length: 3474


                                            [__last_response_headers] => HTTP/1.1 400 Bad Request
Server: Microsoft-IIS/8.0
X-Powered-By: ASP.NET
Date: Wed, 17 Feb 2016 23:18:17 GMT
Content-Length: 0

                                            [__soap_fault] => SoapFault Object
 *RECURSION*
                                        )

                                    [namespace:BingAds\Proxy\ClientProxy:private] => https://bingads.microsoft.com/Reporting/v9
                                )

                            [1] => SoapVar Object
                                (
                                    [enc_type] => 301
                                    [enc_value] => BingAds\Reporting\KeywordPerformanceReportRequest Object
                                        (
                                            [Aggregation] => Daily
                                            [Columns] => Array
                                                (
                                                    [0] => TimePeriod
                                                    [1] => AccountId
                                                    [2] => CampaignId
                                                    [3] => Keyword
                                                    [4] => KeywordId
                                                    [5] => DeviceType
                                                    [6] => BidMatchType
                                                    [7] => Clicks
                                                    [8] => Impressions
                                                    [9] => Ctr
                                                    [10] => AverageCpc
                                                    [11] => Spend
                                                    [12] => QualityScore
                                                )

                                            [Filter] => 
                                            [MaxRows] => 10
                                            [Scope] => BingAds\Reporting\AccountThroughAdGroupReportScope Object
                                                (
                                                    [AccountIds] => Array
                                                        (
                                                            [0] => #myaccountID#
                                                        )

                                                    [AdGroups] => 
                                                    [Campaigns] => 
                                                )

                                            [Sort] => Array
                                                (
                                                    [0] => BingAds\Reporting\KeywordPerformanceReportSort Object
                                                        (
                                                            [SortColumn] => Clicks
                                                            [SortOrder] => Ascending
                                                        )

                                                )

                                            [Time] => BingAds\Reporting\ReportTime Object
                                                (
                                                    [CustomDateRangeEnd] => 
                                                    [CustomDateRangeStart] => 
                                                    [PredefinedTime] => Today
                                                )

                                            [Format] => Csv
                                            [Language] => 
                                            [ReportName] => My Keyword Performance Report
                                            [ReturnOnlyCompleteData] => 
                                        )

                                    [enc_stype] => KeywordPerformanceReportRequest
                                    [enc_ns] => https://bingads.microsoft.com/Reporting/v9
                                )

                        )

                )

            [4] => Array
                (
                    [file] => /home/ubuntu/workspace/index.php
                    [line] => 4
                    [args] => Array
                        (
                            [0] => /home/ubuntu/workspace/BING/PHP/Bing Ads API in PHP/v9/ReportRequests.php
                        )

                    [function] => require_once
                )

        )

    [previous:Exception:private] => 
    [faultstring] => Bad Request
    [faultcode] => HTTP
    [xdebug_message] => ( ! ) SoapFault: Bad Request in /home/ubuntu/workspace/BING/PHP/Bing Ads API in PHP/v9/ReportRequests.php on line 303
Call Stack
#TimeMemoryFunctionLocation
10.0003234016{main}(  ).../index.php:0
20.0019239592require_once( '/home/ubuntu/workspace/BING/PHP/Bing Ads API in PHP/v9/ReportRequests.php' ).../index.php:4
30.27911470864SubmitGenerateReport(  ).../ReportRequests.php:103
40.27911471200SubmitGenerateReport
(  ).../ReportRequests.php:303
50.27911471600__call
(  ).../ReportRequests.php:303

)

1 个答案:

答案 0 :(得分:0)

目前还不是很清楚,您使用的是MSDN上提供的Reports in PHP示例,还是从头开始编写自己的示例?您似乎可能正在尝试将UserName标头元素设置为不受支持的电子邮件地址。要对Microsoft帐户用户进行身份验证,您必须使用OAuth,例如请参阅Server Side OAuth Authentication in PHP。 “错误请求”错误可能是其他内容的结果,所以请分享SOAP请求和响应(如果可用),我很高兴看一看。