using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using Qiniu.Util;
using Newtonsoft.Json;
namespace ConsoleApplication1
{
[JsonObject(MemberSerialization.OptIn)]
class RefreshMode
{
private string[] urls;
[JsonProperty("urls")]
public string[] Urls
{
get { return urls; }
set { urls = value; }
}
public override string ToString()
{
return QiniuJsonHelper.JsonEncode(this);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Threading.Tasks;
using Qiniu.Auth;
using Qiniu.IO;
using Qiniu.IO.Resumable;
using Qiniu.RS;
using Qiniu.Util;
using Qiniu.Auth.digest;
using Qiniu.RPC;
using System.Collections;
using System.IO;
using Newtonsoft.Json.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
String[] str = new string[] { "http://oam23jwg3.bkt.clouddn.com/01" };
RefreshMode refreshMode = new RefreshMode();
refreshMode.Urls = str;
Console.WriteLine(refreshMode.ToString());
Qiniu.Conf.Config.ACCESS_KEY = "xx";
Qiniu.Conf.Config.SECRET_KEY = "xx";
String signingStr = "/v2/tune/refresh\n";
String uri = "http://fusion.qiniuapi.com/v2/tune/refresh";
Mac mac = new Mac();
string access_token = mac.Sign(Qiniu.Conf.Config.Encoding.GetBytes(signingStr));
WebHeaderCollection whc = new WebHeaderCollection();
whc.Add("Authorization", "QBox " + access_token);
//whc.Add("ContentType", "application/json");
byte[] btBodys = Encoding.UTF8.GetBytes(refreshMode.ToString());
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(uri));
request.Headers = whc;
request.Method = "post";
request.ContentType = "application/json";
Console.WriteLine(request.Method);
Console.WriteLine(request.ContentType);
request.GetRequestStream().Write(btBodys, 0, btBodys.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader =new StreamReader(response.GetResponseStream());
string result = reader.ReadToEnd();
reader.Close();
Console.WriteLine(response.StatusCode);
Console.WriteLine(result);
Console.WriteLine(response.Server);
Console.WriteLine(response.ProtocolVersion);
Console.WriteLine(response.ContentLength);
Console.WriteLine(response.LastModified);
}
}
}
注:本文内容来自互联网,旨在为开发者提供分享、交流的平台。如有涉及文章版权等事宜,请你联系站长进行处理。