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详细说明。

  • 相关阅读:
    A.02.01—功能定义—一般定义
    A.02.00—功能定义与唤醒—起始
    A.01.12—模块的输出—通讯(CAN&LIN)
    A.01.11—模块的输出—输出复用和可配
    A.01.10—模块的输出—PWM高端输出
    A.01.09—模块的输出—PWM低端输出
    redis命令
    memcached命令
    kafka命令
    nginx命令
  • 原文地址:https://www.cnblogs.com/kingreatwill/p/5717718.html
Copyright © 2011-2022 走看看