Last active
January 17, 2024 04:41
-
-
Save donma/9a54c7d5417cd3c15b7535949a1b5140 to your computer and use it in GitHub Desktop.
Create an Object in https://api.asm.skype.com/v1/objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string CreateObject(string skypeToken, string skypeId) | |
{ | |
HttpWebRequest httpWebRequestw1 = WebRequest.Create("https://api.asm.skype.com/v1/objects") as HttpWebRequest; | |
httpWebRequestw1.Method = "POST"; | |
httpWebRequestw1.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0"; | |
httpWebRequestw1.Headers.Add("Accept-Language", "zh-tw,zh;q=0.8,en-us;q=0.5,en;q=0.3"); | |
httpWebRequestw1.Headers.Add("Accept-Encoding", "gzip, deflate"); | |
httpWebRequestw1.Referer = ("https://web.skype.com/"); | |
//Authorization: skype_token [your_skype_token] | |
httpWebRequestw1.Headers.Add("Authorization", "skype_token " + skypeToken); | |
httpWebRequestw1.Headers.Add("Origin", "https://web.skype.com"); | |
httpWebRequestw1.Headers.Add("X-Client-Version", "1418/8.55.0.123//"); | |
httpWebRequestw1.KeepAlive = true; | |
httpWebRequestw1.ContentType = "application/json; charset=UTF-8"; | |
//要補上 8: | |
var str = "{\"permissions\":{\"" + "8:" + skypeId + "\":[\"read\"]},\"type\":\"pish/image\",\"filename\":\"ddd.jpg\"}"; | |
byte[] bytesw1 = Encoding.UTF8.GetBytes(str); | |
using (Stream requestStream = httpWebRequestw1.GetRequestStream()) | |
{ | |
requestStream.Write(bytesw1, 0, bytesw1.Length); | |
} | |
var imageInfo = new ResponseImageId(); | |
using (WebResponse response = httpWebRequestw1.GetResponse()) | |
{ | |
StreamReader streamReader = new StreamReader(response.GetResponseStream()); | |
string end = streamReader.ReadToEnd(); | |
streamReader.Close(); | |
Count += 1; | |
imageInfo = JsonConvert.DeserializeObject<ResponseImageId>(end); | |
return imageInfo.id; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ResponseImageId | |
{ | |
public string id { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment