Exemplo n.º 1
0
        /// <summary>
        /// Send a JSON request in order to execute the function "file.upload"
        /// </summary>
        /// <param name="call"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public DCObject Call(string call, DCObject args)
        {
            JavaScriptSerializer serializer    = new JavaScriptSerializer();
            DCObject             json_response = null;

            try
            {
                DCObject jo = DCObject.Create();
                jo.Push("call", call);
                jo.Push("args", args);
                string normalize = "args" + "jsonp_cb" + args["jsonp_cb"] + "status" + "true"
                                   + "target" + args["target"] + "call" + jo["call"];
                string token2 = Helpers.Md5(normalize);
                string token  = Helpers.Md5(this.user_id + normalize + this.api_key);
                jo.Push("auth", this.user_id + ":" + token);
                string json_encoded = serializer.Serialize((object)jo);;
                string response     = Helpers.Curl(this.base_url + "/api", json_encoded);
                JavaScriptSerializer deserializer = new JavaScriptSerializer();
                Dictionary <object, Dictionary <object, object> > deserializedDictionary1 =
                    (Dictionary <object, Dictionary <object, object> >)deserializer.Deserialize(response, typeof(Dictionary <object, Dictionary <object, object> >));
                json_response = DCObject.Create();
                json_response.Push("status", (deserializedDictionary1["result"])["status"]);
                json_response.Push("url", deserializedDictionary1["result"]["url"]);
            }
            catch (Exception)
            {
                throw;
            }
            return(json_response);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Upload a video file
        /// </summary>
        /// <param name="status"></param>
        /// <param name="jsonpCb"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public DCObject FileUpload(Boolean status, string jsonpCb, string target)
        {
            DCObject args = DCObject.Create();

            if (status)
            {
                args.Push("status", true);
            }

            if (!target.Equals(""))
            {
                args.Push("target", target);
            }
            if (!jsonpCb.Equals(""))
            {
                args.Push("jsonp_cb", jsonpCb);
            }
            return((DCObject)this.Call("file.upload", args));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create a media
        /// </summary>
        /// <param name="url"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public string MediaCreate(string url, string name)
        {
            DCObject urlArgs   = DCObject.Create().Push("url", url);
            DCObject titleargs = DCObject.Create().Push("title", name);

            urlArgs.Push("meta", titleargs);

            DCObject result = this.Call("media.create", urlArgs, name);

            return(result.Pull("id"));
        }