新浪微博如何通过获取的数据发送微博信息

无聊的一个人啊 2011-05-31 06:15:16
新浪微博如何通过获取的 oauth_token oauth_token_secret 发送微博信息
如:
oauth_token=a593cf5e531efd1219fbca9b0a62f654&oauth_token_secret=d3f69686b4446f19f348cc0503b90958&user_id=2155022943
...全文
908 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
秦宇升 2013-09-23
  • 打赏
  • 举报
回复
我用我的帐号和key 怎么报“远程服务器返回错误: (400) 错误的请求。”
  • 打赏
  • 举报
回复
vv
问题是,我用新浪的账号登陆时,先到新浪登陆,然后新浪跳到我的站点来,我怎么用
获取到的oauth_token oauth_token_secret 发送微
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 wxr0323 的回复:]

protected void Page_Load(object sender, EventArgs e)
{

string username = "473@me3g.cn";
string password = "000000";
string usernamePassword = username + ":" +……
[/Quote]

问题是,我用新浪的账号登陆时,先到新浪登陆,然后新浪跳到我的站点来,我怎么用
获取到的oauth_token oauth_token_secret 发送微博信息
子夜__ 2011-05-31
  • 打赏
  • 举报
回复
protected void Page_Load(object sender, EventArgs e)
{

string username = "473@me3g.cn";
string password = "000000";
string usernamePassword = username + ":" + password;

//准备调用的URL及需要POST的数据:

string url = "http://api.t.sina.com.cn/statuses/update.xml?source=" + ConfigurationManager.AppSettings["WB_AKEY"];
string content = "新的一天新的开始!";
string data ="status=" + content;

//准备用于发起请求的HttpWebRequest对象
WebRequest webRequest = WebRequest.Create(url);
HttpWebRequest httpRequest = webRequest as HttpWebRequest;
//准备用于用户验证的凭据
CredentialCache myCache = new CredentialCache();
myCache.Add(new Uri(url), "Basic", new NetworkCredential(username, password));
httpRequest.Credentials = myCache;
httpRequest.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new System.Text.ASCIIEncoding().GetBytes(usernamePassword)));
//发起POST请求
httpRequest.Method = "POST";
httpRequest.ContentType = "application/x-www-form-urlencoded";
System.Text.Encoding encoding = System.Text.Encoding.ASCII;
byte[] bytesToPost = encoding.GetBytes(data);
httpRequest.ContentLength = bytesToPost.Length;

Stream requestStream = httpRequest.GetRequestStream();
requestStream.Write(bytesToPost, 0, bytesToPost.Length);
requestStream.Close();
string responseContent = "";
try
{
//获取服务端的响应内容
WebResponse wr = httpRequest.GetResponse();
Stream receiveStream = wr.GetResponseStream();

using (StreamReader reader = new StreamReader(receiveStream, System.Text.Encoding.UTF8))
{
responseContent = reader.ReadToEnd();
}
}
catch (Exception ex)
{
responseContent = ex.Message;
}
Response.Write(responseContent);
}
hzsasheng 2011-05-31
  • 打赏
  • 举报
回复
看看新浪API吧,,有.net的SDK下载,可以参考,基本就是你先发送一个请求过去,新浪给你返回一个token,然后你把token处理再返回给新浪,就通信上了,然后调用它的发送微博api补齐参数,就能发送了

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧