在Pinterest上发布图钉时,我收到504错误消息。它可以在Postman中使用,但不能在C#中使用。
public void postPinterest(string access_token,string boardname,string note,string image_url)
{
try
{
string uri = "https://api.pinterest.com/v1/pins";
System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri);
string parameters = "access_token="
+ access_token
+ "&board="
+ boardname
+ "¬e="
+ note
+ "&image_url="
+ image_url;
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
byte[] bytes = Encoding.ASCII.GetBytes(parameters);
System.IO.Stream os = null;
req.ContentLength = bytes.Length;
os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
System.Net.WebResponse webResponse = req.GetResponse();
System.IO.Stream stream = webResponse.GetResponseStream();
System.IO.StreamReader reader = new System.IO.StreamReader(stream);
string response = reader.ReadToEnd();
}
catch(Exception ex)
{
throw ex;
}
}
}