Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update demo/remove token based examples #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 43 additions & 25 deletions java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
### 源码构建

```shell
mvn clean install
sh build.sh
```

### maven使用
Expand All @@ -29,7 +29,7 @@ mvn clean install
<version>${version}</version>
</dependency>
```
最新版本![Maven](https://img.shields.io/maven-central/v/com.baidu.dev2/baiduads-sdk.svg)
<font color=red>备注:请在Maven仓库上找最新的版本。</font>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以不改这个吗?



## 使用方式
Expand All @@ -42,36 +42,54 @@ mvn clean install
* API tests for AccountService
*/
public class AccountServiceTest {

private final AccountService api = new AccountService();

private static String appId = "{appId}";

private static Long userId = 0L; // {userId}

private static String authCode = "{authCode}";

private static String secretKey = "{secretKey}";

/**
* @throws ApiException
* if the Api call fails
*/
@Test
public void getAccountInfoTest() throws ApiException {
// init header
// get accessToken
OAuthService oAuthService = new OAuthService();
GetAccessTokenRequest request = new GetAccessTokenRequest();
request.setAppId(appId);
request.setUserId(userId);
request.setAuthCode(authCode);
request.setSecretKey(secretKey);
GetAccessTokenResponse response = oAuthService.getAccessToken(request);
String accessToken = response.getData().getAccessToken();

// init service
AccountService accountService = new AccountService();
// init request header
ApiRequestHeader requestHeader = new ApiRequestHeader();
requestHeader.setUsername("********");
requestHeader.setPassword("********");
requestHeader.setToken("****************");

// init request body
ApiAccountQueryRequest request = new ApiAccountQueryRequest();
List<String> accountFields = new ArrayList<>();
accountFields.add("pictureOptimizeSegmentStatus");
request.setAccountFields(accountFields);

// init request wrapper
// set oauth info
requestHeader.setUserName("{userName}");
requestHeader.setAccessToken(accessToken);

// init request
ApiAccountQueryRequest queryRequest = new ApiAccountQueryRequest();
ArrayList<String> fields = new ArrayList<>();
fields.add("pictureOptimizeSegmentStatus");
fields.add("balance");
fields.add("userLevel");
queryRequest.setAccountFields(fields);

// init requster wrapper
GetAccountInfoRequestWrapper requestWrapper = new GetAccountInfoRequestWrapper();
requestWrapper.setHeader(requestHeader);
requestWrapper.setBody(request);


GetAccountInfoResponseWrapper response = api.getAccountInfo(requestWrapper);
requestWrapper.setBody(queryRequest);

Assert.assertTrue(response.getHeader().getStatus() == 0);
GetAccountInfoResponseWrapper responseWrapper = accountService.getAccountInfo(requestWrapper);
Assert.assertTrue(responseWrapper.getHeader().getStatus() == 0);

}
}
Expand All @@ -86,10 +104,10 @@ public class AccountServiceTest {

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*CampaignFeedService* | [**addCampaignFeed**](docs/CampaignFeedService.md#addCampaignFeed) | **POST** /json/feed/v1/CampaignFeedService/addCampaignFeed |
*CampaignFeedService* | [**deleteCampaignFeed**](docs/CampaignFeedService.md#deleteCampaignFeed) | **POST** /json/feed/v1/CampaignFeedService/deleteCampaignFeed |
*CampaignFeedService* | [**getCampaignFeed**](docs/CampaignFeedService.md#getCampaignFeed) | **POST** /json/feed/v1/CampaignFeedService/getCampaignFeed |
*CampaignFeedService* | [**updateCampaignFeed**](docs/CampaignFeedService.md#updateCampaignFeed) | **POST** /json/feed/v1/CampaignFeedService/updateCampaignFeed |
*CampaignFeedService* | [**addCampaignFeed**](docs/CampaignFeedService.md#addCampaignFeed) | **POST** /json/feed/v1/CampaignFeedService/addCampaignFeed |
*CampaignFeedService* | [**deleteCampaignFeed**](docs/CampaignFeedService.md#deleteCampaignFeed) | **POST** /json/feed/v1/CampaignFeedService/deleteCampaignFeed |
*CampaignFeedService* | [**getCampaignFeed**](docs/CampaignFeedService.md#getCampaignFeed) | **POST** /json/feed/v1/CampaignFeedService/getCampaignFeed |
*CampaignFeedService* | [**updateCampaignFeed**](docs/CampaignFeedService.md#updateCampaignFeed) | **POST** /json/feed/v1/CampaignFeedService/updateCampaignFeed |


## 讨论
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ public class CreateFeedAd {

static {
header = new ApiRequestHeader();
header.setPassword("xxxxx");
header.setUsername("xxxxx");
header.setToken("xxxxx");
header.setAccessToken("xxxxx"); // accessToken需要通过授权环节生成
header.setUserName("xxxxx"); // 替换成自己的用户名
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ public class CreateSearchAd {

static {
header = new ApiRequestHeader();
header.setPassword("xxxxx");
header.setUsername("xxxxx");
header.setToken("xxxxx");
header.setAccessToken("xxxxx"); // accessToken需要通过授权环节生成
header.setUserName("xxxxx"); // 替换成自己的用户名
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ public static void main(String[] args) {

// init requset header
ApiRequestHeader requestHeader = new ApiRequestHeader();
requestHeader.setToken("xxxxx"); // 替换为自己的token
requestHeader.setUsername("xxxxx"); // 替换为自己的用户名
requestHeader.setPassword("xxxxx"); // 替换为自己的密码
requestHeader.setAccessToken("xxxxx"); // 替换为授权生成的accessToken
requestHeader.setUserName("xxxxx"); // 替换为自己的用户名

// init requset
ApiAccountQueryRequest request = new ApiAccountQueryRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ public class BalanceServiceTest {
public void before() {
balanceService = new BalanceService();
header = new ApiRequestHeader();
header.setUsername("xxxxx"); // 替换为自己的用户名
header.setPassword("xxxxx"); // 替换为自己的密码
header.setToken("xxxxx"); // 替换为自己的token
header.setAccessToken("xxxxx"); // 替换为授权生成的accessToken
header.setUserName("xxxxx"); // 替换为自己的用户名
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ public void before() {
service = new MarketingFileService();
header = new ApiRequestHeader();
// 请填写自己的信息
header.setToken("xxxxx");
header.setUsername("xxxxx");
header.setPassword("xxxxx");
header.setTarget("xxxxx");
header.setAccessToken("xxxxx"); // 替换为授权生成的accessToken
header.setUserName("xxxxx"); // 替换为自己的用户名
}

/***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ public class PaymentServiceTest {
public void before() {
paymentService = new PaymentService();
header = new ApiRequestHeader();
header.setUsername("xxxxx"); // 替换为自己的用户名
header.setPassword("xxxxx"); // 替换为自己的密码
header.setToken("xxxxx"); // 替换为自己的token
header.setAccessToken("xxxxx"); // 替换为授权生成的accessToken
header.setUserName("xxxxx"); // 替换为自己的用户名
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ public void before() {
service = new VideoUploadService();
header = new ApiRequestHeader();
// 请填写自己的信息
header.setToken("xxxxx");
header.setUsername("xxxxx");
header.setPassword("xxxxx");
header.setTarget("xxxxx");
header.setAccessToken("xxxxx"); // 替换为授权生成的accessToken
header.setUserName("xxxxx"); // 替换为自己的用户名
}

@Test
Expand Down
Empty file modified java/build.sh
100644 → 100755
Empty file.
Empty file modified java/cmc.sh
100644 → 100755
Empty file.
Empty file modified java/postBuild.sh
100644 → 100755
Empty file.
1 change: 0 additions & 1 deletion python/baiduads-sdk-auto/docs/KeywordType.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ Name | Type | Description | Notes
**top_page_views** | **int** | | [optional]
**top_p_clicks** | **int** | | [optional]
**campaign_bid_type** | **int** | | [optional]
**es_conversion** | **float** | | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Expand Down