zoukankan      html  css  js  c++  java
  • 阿里云直播SDK

    阿里云sdk:https://develop.aliyun.com/sdk/csharp?spm=5176.doc27234.2.4.QiJb9l

    Github:https://github.com/aliyun/aliyun-openapi-net-sdk

    云直播产品页面:https://www.aliyun.com/product/live?spm=5176.7960203.237031.168.LRN4J3

    SDK使用:

    步骤

    第一步,需要初始化Client。

    1.与阿里云SDK相关的类都在名称空间 Aliyun.Api 下;
    2.AliyunClient 是与 Open API 交互的接口,SDK 的操作都是通过 IAliyunClient 完成的;
    3.AliyunClient 可以复用,建议设置成应用程序全局唯一的;
    4.用户可以调用 SetTimeout 方法来设置SDK调用接口的连接超时时间。
    示例代码如下:

    private static string serverUrl = "<serverUrl>";//http://slb.aliyuncs.com/
    private static string accessKeyId = "<accessKeyId>";
    private static string accessKeySecret = "<accessKeySecret>";

    private static IAliyunClient client = new DefaultAliyunClient(serverUrl, accessKeyId, accessKeySecret);

    第二步, 实例化request,给请求实例赋值并调用API获取返回结果。

    调用步骤
    1.实例化一个请求类,根据调用的API的不同版本实例化不同命名空间下的请求类;
    2.给请求类实例赋值;
    3.调用接口返回调用结果。

    包名称规则:
    请求类名称空间:Aliyun.Api.[PPP].[PPP][yyyymmdd].Request
    响应类命名空间:Aliyun.Api.[PPP].[PPP][yyyymmdd].Response
    [PPP]为产品名称缩写大写;[yyyymmdd]为API版本号

    下面以负载均衡 API 2014-05-15版为例,SLB对应产品名称,20140515对应调用的API版本。
    请求类名称空间:Aliyun.Api.SLB.SLB20140515.Request
    响应类名称空间:Aliyun.Api.SLB.SLB20140515.Response

    下面以创建SLB实例为例,给出示例代码如下:

    public static void CreateLoadBalancer()
    {
            CreateLoadBalancerRequest request = new CreateLoadBalancerRequest();
            request.RegionId = "<RegionId>";
            request.AddressType = "<AddressType>";
            request.Bandwidth = <Bandwidth>
            request.InternetChargeType = "<InternetChargeType>";

            try
            {
                    CreateLoadBalancerResponse response = client.Execute(request);
                    if (string.IsNullOrEmpty(response.Code))
                    {//创建成功
                    String loadBlancerId = response.LoadBalancerId;//取得实例ID
                    }
                    else
                    {//创建失败
                    String errorCode = response.Code;//取得错误码
                    String message = response.Message;//取得错误信息
                    }
            }
            catch (Exception e)
            {
                    //TODO: handle exception
            }
    }

    查看 API

    安装SDK后,您可以通过调用API来访问、管理阿里云产品,以下是阿里云开放的API的产品,选择产品查看产品API详细说明。

  • 相关阅读:
    探究 encode 和 decode 的使用问题(Python)
    C语言结构体在内存中的存储情况探究------内存对齐
    文件基本操作 (C语言)
    利用Xamaria构建Android应用-公交发车信息屏
    ChakraCore ,Net托管编程
    Go并发与.Net TAP
    码农视角
    让isis支持高德地图
    Fedora Server 上配置 MariaDb 集群
    .Net Sokcet 异步编程
  • 原文地址:https://www.cnblogs.com/kingreatwill/p/5717718.html
Copyright © 2011-2022 走看看