2 回答

TA貢獻2021條經驗 獲得超8個贊
請求是空的,即,您沒有像 SubmitGenerateReport 期望的那樣設置 ReportRequest,例如,它不應該是一個數組。我通過從報告示例助手中注釋掉這一行來重現相同的錯誤:
//$request->ReportRequest = $reportRequest;
GitHub 上有一個示例,創建請求并使用示例助手提交報告請求等。請參閱 ServiceClient 的詳細信息(示例用法+ SDK 類),以幫助映射到您自己的實現。
為了獲取所有示例和幫助程序類,我克隆了 Bing Ads SDK 存儲庫:
git clone https://github.com/BingAds/BingAds-PHP-SDK.git
然后通過 Composer 從示例目錄安裝 SDK(安裝說明位于docs.microsoft.com):
PS C:\dev\github\BingAds-PHP-SDK\samples> composer require microsoft/bingads
No composer.json in current directory, do you want to use the one at C:\dev\github\BingAds-PHP-SDK? [Y,n]? n
Using version v0.12.13.4 for microsoft/bingads
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing microsoft/bingads (v0.12.13.4): Downloading (100%)
Writing lock file
Generating autoload files
PS C:\dev\github\BingAds-PHP-SDK\samples> php.exe .\v13\ReportRequests.php
You need to provide consent for the application to access your Bing Ads Bing Ads accounts. Copy and paste this authorization endpoint into a web browser and sign in with a Microsoft account with access to a Bing Ads account:
https://login.live-int.com/oauth20_authorize.srf?scope=bingads.manage&prompt=login&client_id=db41b09d-6e50-4f4a-90ac-5a99caefb52f&response_type=code&redirect_uri=https://login.live-int.com/oauth20_desktop.srf
After you have granted consent in the web browser for the application to access your Bing Ads accounts, please enter the response URI that includes the authorization 'code' parameter:
將每個 OAuth 同意指令的結果粘貼到上面的腳本中,然后 ReportRequests.php 應該繼續執行,即提交報告請求。
這是 $reportRequest 的 var_dump:
object(SoapVar)#79 (4) {
["enc_type"]=>
int(301)
["enc_value"]=>
object(Microsoft\BingAds\V13\Reporting\AccountPerformanceReportRequest)#35 (11) {
["Aggregation"]=>
string(6) "Weekly"
["Columns"]=>
array(9) {
[0]=>
string(10) "TimePeriod"
[1]=>
string(9) "AccountId"
[2]=>
string(11) "AccountName"
[3]=>
string(6) "Clicks"
[4]=>
string(11) "Impressions"
[5]=>
string(3) "Ctr"
[6]=>
string(10) "AverageCpc"
[7]=>
string(5) "Spend"
[8]=>
string(8) "DeviceOS"
}
["Filter"]=>
NULL
["Scope"]=>
object(Microsoft\BingAds\V13\Reporting\AccountReportScope)#77 (1) {
["AccountIds"]=>
array(1) {
[0]=>
int(MyAccountIdWasHere)
}
}
["Time"]=>
object(Microsoft\BingAds\V13\Reporting\ReportTime)#80 (4) {
["CustomDateRangeEnd"]=>
NULL
["CustomDateRangeStart"]=>
NULL
["PredefinedTime"]=>
string(9) "Yesterday"
["ReportTimeZone"]=>
NULL
}
["ExcludeColumnHeaders"]=>
NULL
["ExcludeReportFooter"]=>
NULL
["ExcludeReportHeader"]=>
NULL
["Format"]=>
string(3) "Tsv"
["ReportName"]=>
string(29) "My Account Performance Report"
["ReturnOnlyCompleteData"]=>
bool(false)
}
["enc_stype"]=>
string(31) "AccountPerformanceReportRequest"
["enc_ns"]=>
string(43) "https://bingads.microsoft.com/Reporting/v13"
}
我希望這有幫助!

TA貢獻1827條經驗 獲得超8個贊
是的,之前的答案是正確的 - 請求參數結構不正確。這是我沒有 bing sdk 的工作代碼的一部分。
$headers = [
new SoapHeader(
'https://bingads.microsoft.com/Reporting/v13',
'CustomerAccountId',
...
),
new SoapHeader(
'https://bingads.microsoft.com/Reporting/v13',
'CustomerId',
...
),
new SoapHeader(
'https://bingads.microsoft.com/Reporting/v13',
'DeveloperToken',
...
),
new SoapHeader(
'https://bingads.microsoft.com/Reporting/v13',
'AuthenticationToken',
$this->getToken()
),
];
$context = [
'http' => [
'header' => "Authorization: Bearer {$this->getOAuthToken()}",
],
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
];
$options = array(
'stream_context' => stream_context_create($context),
'trace' => TRUE,
'exceptions' => TRUE,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
// Disable keep-alive to avoid 'Process open FD table is full'
'keep-alive' => FALSE,
'user_agent' => 'BingAdsSDKPHP ' . '13.0.1 ' . PHP_VERSION,
/**
* Map long type to string type. For details, see
* from_long_xml and to_long_xml callbacks.
*/
'typemap' => array(
array(
'type_ns' => 'http://www.w3.org/2001/XMLSchema',
'type_name' => 'xs:long',
'to_xml' => 'to_long_xml',
'from_xml' => 'from_long_xml'
),
)
);
$SoapClient = new SOAPClient(static::WSDL_REPORTING, $options);
$SoapClient->__setSoapHeaders($headers);
并要求自己
$request = [
'ReportRequest' => new SoapVar(
[
'Format' => 'Tsv',
'ReportName' => 'My Account Performance Report',
'ReturnOnlyCompleteData' => false,
'Aggregation' => 'Weekly',
'Scope' => ['AccountIds' => [...]],
'Time' => ['PredefinedTime' => 'Yesterday'],
'Columns' => [
"TimePeriod",
"AccountId",
"AccountName",
"Clicks",
"Impressions",
"Ctr",
"AverageCpc",
"Spend",
"DeviceOS"
]
],
SOAP_ENC_OBJECT,
'AccountPerformanceReportRequest',
"https://bingads.microsoft.com/Reporting/v13"
)];
$response = $SoapClient->SubmitGenerateReport($request);
- 2 回答
- 0 關注
- 263 瀏覽
添加回答
舉報