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