网站调用新浪微博内容(1.配置文件下载SDK.Json和RestSharp两个程序集)

优采云 发布时间: 2021-12-21 00:03

  网站调用新浪微博内容(1.配置文件下载SDK.Json和RestSharp两个程序集)

  1. 先下载SDK()。 SDK 依赖于两个程序集,Newtonsoft.Json 和 RestSharp。具体请参考使用RestSharp库消费Restful Service。主要有QzoneContext(QQ登录的上下文数据)和QOpenClient(QQ互联API入口)两个类,其他类主要是模型和配置类。

  2.在配置文件中加入如下内容:

  

   1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

  

  3.我这里使用的是MVC模式,后台代码如下:

  

   1 public ActionResult Index()

2 {

3 //this.Session[RETURNURL] = returnUrl;

4 var context = new QzoneContext();

5 string state = Guid.NewGuid().ToString().Replace("-", "");

6 Session["requeststate"] = state;

7 string scope = "get_user_info,add_share,list_album,upload_pic,check_page_fans,add_t,add_pic_t,del_t,get_repost_list,get_info,get_other_info,get_fanslist,get_idolist,add_idol,del_idol,add_one_blog,add_topic,get_tenpay_addr";

8 model.authenticationUrl = context.GetAuthorizationUrl(state, scope);

9

10 return View(model);

11 }

  

  首页如下:

  

  @model dynamic

@{

Layout = null;

}

Index

用户名:<br />

密 码:<br />

~/Images/qq.pngQQ账号登录

  

  测试界面如下:点击实现QQ登录

  

  虽然通过这种方式实现了登录,但只能使用自己开发者的QQ账号登录。如果您想使用任何QQ账号登录,应用程序需要通过TX审核。 . .

  注意:

  如果是本地测试,修改IIS发布的网站端口为80,修改C:\Windows\System32\drivers\etc中的hosts文件,在IIS和对应的域名:

  

  转移:

0 个评论

要回复文章请先登录注册


官方客服QQ群

微信人工客服

QQ人工客服


线