Bing 广告活动管理

Bing ads Campaign Management

我最近开始使用 Bing Ads api 来管理我的广告和活动,但我在验证用户(不是 oauth 验证)时遇到问题。

我通过以下方式使用 oauth 验证了我的用户

private String devToken = "ZZZZZ";
private String clientId = "AAA0BBB-XXXX-AAAAA";
protected static String UserName = "a.v@h.c";
protected static String Password = "********";

// To get the initial access and refresh tokens you must call requestAccessAndRefreshTokens with the authorization redirection URL.
OAuthTokens tokens = oAuthDesktopMobileAuthCodeGrant.requestAccessAndRefreshTokens(url);

System.out.println("Access token: " + tokens.getAccessToken());
System.out.println("Refresh token: " + tokens.getRefreshToken());

authorizationData = new AuthorizationData();
authorizationData.setDeveloperToken(getDevToken());
authorizationData.setAuthentication(oAuthDesktopMobileAuthCodeGrant);

这很好地验证了我的用户,因为我可以使用 ICustomerManagementService.class 很好地获取帐户相关信息

customerServiceClient = new ServiceClient<>(authorizationData, ICustomerManagementService.class);
ArrayOfAccount accounts = searchAccountsByUserId(user.getId());

以上内容完美无缺。但是当我尝试对ICampaignManagementService.class做同样的事情时

campaignServiceClient = new ServiceClient<>(authorizationData, ICampaignManagementService.class);
GetAdsByAdGroupIdRequest cReq = new GetAdsByAdGroupIdRequest();
cReq.setAdGroupId(1234567890L);
campaignServiceClient.getService().getAdsByAdGroupId(cReq);

我收到错误代码 106,表示用户未获得授权。

The user does not represent a authorized developer.
106

在这方面有什么帮助吗?

请尝试设置 CustomerId 和 CustomerAccountId header 元素(AuthorizationData 的 CustomerId 和 AccountId)。这些 header 不适用于客户管理服务,但适用于营销活动管理服务。如果这不能解决问题,请随时将 SOAP 请求 + 响应发送到 support 以进行调查。希望对您有所帮助!