示例代码

最近更新时间:2019-05-27 15:32:42

1. SDK 代码下载

开发语言 github 地址
PHP https://github.com/QcloudApi/qcloudapi-sdk-php
Python https://github.com/QcloudApi/qcloudapi-sdk-python
Java https://github.com/QcloudApi/qcloudapi-sdk-java
.Net https://github.com/QcloudApi/qcloudapi-sdk-dotnet
Node.js https://github.com/CFETeam/qcloudapi-sdk

将示例代码中的 YOUR_SECRET_ID 和 YOUR_SECRET_KEY 替换成实际的 SecretId 和 SecretKey。
示例代码仅供参考, 请根据实际情况使用。

2. Java 语言的示例代码

import java.util.TreeMap;

import com.qcloud.QcloudApiModuleCenter;
import com.qcloud.Module.*;
import com.qcloud.Utilities.MD5;


public class Demo {
        public static void main(String[] args) {
                TreeMap<String, Object> config = new TreeMap<String, Object>();

                config.put("SecretId", "");
                config.put("SecretKey", "");
                config.put("RequestMethod", "POST");
                config.put("DefaultRegion", "gz");
                QcloudApiModuleCenter module = new QcloudApiModuleCenter(new Yunsou(), config);
                TreeMap<String, Object> params = new TreeMap<String, Object>();
                try{        
                        params.put("appId", "xxxx0002");
                        params.put("search_query", "qq");
                        System.out.println(module.call("DataSearch", params));

//                        TreeMap<String, Object> params2 = new TreeMap<String, Object>();
//                        params2.put("appId", "xxxx0002");
//                        params2.put("op_type", "add");
//                        params2.put("contents.0.title", "test");
//                        params2.put("contents.0.contents", "qq");
//                        params2.put("contents.0.id", "12");
//                        params2.put("contents.0.score", "12");
//                        params2.put("contents.0.test", "12");
//                        
//                        System.out.println(module.call("DataManipulation", params2));
                }
                catch (Exception e) {
                        System.out.println(e.getMessage());
                }
        }
}