Commit dab0e56945055a92443b012c430012689cef9b73
1 parent
07f03aba
更新命名规则
Showing
1 changed file
with
102 additions
and
0 deletions
00.公共组件/1.3sdk.md
| 1 | +-## 下载 | |
| 2 | +-* [sdk_java 下载](http://console.open.cnlive.com/open/sdk/open-sdk_java_1.1.zip) | |
| 3 | +-* [iOS 播放和推流SDK及文档下载(金山版)] (http://bj.gitlab.cnlive.com/ios-team/CNLivePlayerStreamerSDKDemo/tree/master) | |
| 4 | +-* [iOS 短视频SDK及文档下载(金山版)] (http://bj.gitlab.cnlive.com/ios-team/CNLiveShortVideoSDKDemo.git) | |
| 5 | +-* [iOS 云存储SDK及文档下载(金山版)] (http://bj.gitlab.cnlive.com/ios-team/CNLiveUploadSDKDemo) | |
| 6 | +-* [iOS 互动聊天 SDK及文档下载] (http://bj.gitlab.cnlive.com/ios-team/CNLiveTIMChatSDKDemo) | |
| 7 | +-* [iOS 用户系统SDK及文档下载] (http://bj.gitlab.cnlive.com/ios-team/CNLiveUserSystemSDKDemo/tree/master) | |
| 8 | +-* [iOS 统计SDK及文档下载] (http://bj.gitlab.cnlive.com/ios-team/CNLiveStatSDKDemo/tree/master) | |
| 9 | +-* [iOS 播放和推流SDK及文档下载(七牛版)] (http://bj.gitlab.cnlive.com/ios-team/CNLiveStreamingKitSDKDemo/tree/master) | |
| 10 | +-* [iOS 支付SDK及文档下载] (http://bj.gitlab.cnlive.com/ios-team/CNLivePaySDKDemo) | |
| 11 | +-* [iOS SDK App示例程序] (http://bj.gitlab.cnlive.com/ios-team/LiveVideoCloud) | |
| 12 | +-* [Android 推流 SDK及文档下载] (http://bj.gitlab.cnlive.com/cnlive-team/CNStreamDemo/tree/master) | |
| 13 | +-* [Android 短视频 SDK及文档下载] (http://bj.gitlab.cnlive.com/cnlive-team/CNLiveShortVideoDemo.git) | |
| 14 | +-* [Android 云存储 SDK及文档下载] (http://bj.gitlab.cnlive.com/cnlive-team/CNUploadDemo.git) | |
| 15 | +-* [Android 播放器 SDK及文档下载] (http://bj.gitlab.cnlive.com/cnlive-team/CNVideoDemo.git) | |
| 16 | +-* [Android 互动聊天 SDK及文档下载] (http://bj.gitlab.cnlive.com/cnlive-team/CNIMDemo.git) | |
| 17 | +-* [Android 统计 SDK及文档下载] (http://bj.gitlab.cnlive.com/cnlive-team/CNAnalyticsDemo.git) | |
| 18 | +-* [Android 用户 SDK及文档] (http://bj.gitlab.cnlive.com/cnlive-team/CNUserDemo.git) | |
| 19 | +-* [Android 支付 SDK及文档] (http://bj.gitlab.cnlive.com/cnlive-team/CNLivePayDemo.git) | |
| 20 | +-* [Android SDK App示例程序] (http://bj.gitlab.cnlive.com/cnlive-team/CNLiveApp.git) | |
| 21 | +- | |
| 22 | +-## java 示例代码 | |
| 23 | +-```java | |
| 24 | +- | |
| 25 | +-package com.cnlive.open.sdk; | |
| 26 | +- | |
| 27 | +-import java.io.IOException; | |
| 28 | +- | |
| 29 | +-import java.util.HashMap; | |
| 30 | +-import java.util.Map; | |
| 31 | +- | |
| 32 | +-import org.apache.http.NameValuePair; | |
| 33 | +-import org.apache.http.client.entity.UrlEncodedFormEntity; | |
| 34 | +-import org.apache.http.client.methods.CloseableHttpResponse; | |
| 35 | +-import org.apache.http.client.methods.HttpUriRequest; | |
| 36 | +-import org.apache.http.client.methods.RequestBuilder; | |
| 37 | +-import org.apache.http.impl.client.CloseableHttpClient; | |
| 38 | +-import org.apache.http.impl.client.HttpClients; | |
| 39 | +-import org.apache.http.message.BasicNameValuePair; | |
| 40 | +-import org.apache.http.util.EntityUtils; | |
| 41 | +- | |
| 42 | +-public class Example { | |
| 43 | +- | |
| 44 | +- public static void main(String[] args) { | |
| 45 | +- //appId,appKey 到http://open.cnlive.com 后台获取。 | |
| 46 | +- String appId = "appId"; | |
| 47 | +- String appKey = "appKey"; | |
| 48 | +- Map<String,String> map = new HashMap<>(); | |
| 49 | +- map.put("appId", appId); | |
| 50 | +- | |
| 51 | +- //添加业务参数 | |
| 52 | +- map.put("param1", ""); | |
| 53 | +- map.put("param2", ""); | |
| 54 | +- map.put("param3", ""); | |
| 55 | +- | |
| 56 | +- String api = "http://api.cnlive.com/open/api2/..."; | |
| 57 | +- | |
| 58 | +- | |
| 59 | +- //生成 get 请求方法的url | |
| 60 | +- String url_get = OpenUtil.buildURL(api, map, appKey); | |
| 61 | +- System.out.println(url_get); | |
| 62 | +- | |
| 63 | +- //post 方式调用 | |
| 64 | +- String sign = OpenUtil.sign(map, appKey); | |
| 65 | +- System.out.println(sign); | |
| 66 | +- map.put("sign", sign); | |
| 67 | +- | |
| 68 | +- //使用apache HttpClient 工具调用。 httpclient 4.3.6 | |
| 69 | +- CloseableHttpClient httpClient = HttpClients.createDefault(); | |
| 70 | +- try { | |
| 71 | +- List<NameValuePair> params = new ArrayList<NameValuePair>(); | |
| 72 | +- for (String k : map.keySet()) { | |
| 73 | +- params.add(new BasicNameValuePair(k,map.get(k))); | |
| 74 | +- } | |
| 75 | +- | |
| 76 | +- HttpUriRequest httpUriRequest = RequestBuilder.post() | |
| 77 | +- .setUri(url) | |
| 78 | +- .setEntity(new UrlEncodedFormEntity(params,"UTF-8")) | |
| 79 | +- .build(); | |
| 80 | +- CloseableHttpResponse rep = httpClient.execute(httpUriRequest); | |
| 81 | +- try { | |
| 82 | +- //输出,或转化为java bean对象 | |
| 83 | +- System.out.println(EntityUtils.toString(rep.getEntity())); | |
| 84 | +- } catch (Exception e) { | |
| 85 | +- e.printStackTrace(); | |
| 86 | +- } finally { | |
| 87 | +- rep.close(); | |
| 88 | +- } | |
| 89 | +- } catch (Exception e) { | |
| 90 | +- // TODO Auto-generated catch block | |
| 91 | +- e.printStackTrace(); | |
| 92 | +- } finally { | |
| 93 | +- try { | |
| 94 | +- httpClient.close(); | |
| 95 | +- } catch (IOException e) { | |
| 96 | +- e.printStackTrace(); | |
| 97 | +- } | |
| 98 | +- } | |
| 99 | +- } | |
| 100 | +-} | |
| 101 | +- | |
| 102 | +-``` | |
| 0 | 103 | \ No newline at end of file | ... | ... |