欢迎访问 夜阑小雨 我的学习碎片档案,这里记录了我的学习内容和工作中经验,希望给您带去帮助。

MSN登陆第三方网站 Windows Live Messager Connect 开发介绍

javascript 夜阑小雨 418℃ 0评论

Windows Live Messenger connection是一套JavaScript的API和REST的服务,使用服务API可以将Windows Live用户 和您的网站应用进行链接。通过使用即时通讯连接API,您可以添加诸如认证,即时消息和内容共享到应用程序的功能,创建直观的体验紧密集成使用Windows Live应用程序。 

开发MSN Live Messager Connect大概步骤 
1、申请应用ID在https://manage.dev.live.com/ 获取wrap_client_id和wrap_client_secret 
2、设置相应的app参数,如图片logo,介绍,服务条款等,设置您网站首页,callback授权页面, 
3、作为第三方网站应用开发 授权请求页面x.php和 授权回调页面y.php 。x用来向live跳转到live的认证页面( https://consent.live.com/connect.aspx )。需传入在步骤1中申请的wrap_client_id和wrap_client_secret,在https://consent.live.com/connect.aspx live用户输入windows live Account和Password , 
经过wiindows live认证后返回授权回调页面y.php,y.php需要接收一个Verification Token 。然后根据返回的Verification Token 向 https://consent.live.com/AccessToken.aspx 发起请求,请求成功后返回 wrap_access_token, wrap_access_token_expires_in,wrap_refresh_token,uid,我们需要将此次获得的结果存到本地数据库中。这样就完成了live用户通过live网站向第三方网站应用授权的整个过程。 由于live的这个wrap_access_token是有失效控制机制的,一旦失效了就需要再重新根据uid和wrap_refresh_token再重新申请一个新的wrap_access_token
4、现在第三方网站即可以根据uid和access_token进行windows live服务的REST接口发起GET或者POST请求。 
5、live服务的根服务是http://apis.live.net 或者 https://apis.live.net 
6、live服务在url中的附加参数 
http://apis.live.net/${api-version}/cid-${profileUID}/ 
api-version是当前服务的版本号,目前是V4.1 
profileUID是live用户的uid,在进行第3步骤的时候会返回给应用开发者。 

7、常见错误
{“Title”:”ErrorResource”,”Code”:1062,”Message”:”Request does not contain a valid PUID.”} accesstoken 失效了
{“Title”:”ErrorResource”,”Code”:1079,”Message”:”Publish operation failed, ensure the activity being posted is not duplicate activity. “} 
申请的权限不够
8、一般的链接申请权限
WL_Activities.Update,WL_Contacts.View,WL_Profiles.View,Messenger.SignIn,WL_Photos.View
9、使用API可以
获取用户的概要
获取用户的联系人
获取用户的联系人分类
获取用户的相册
获取用户的相册文件
发布一个状态
发布一个共享书签
发布一个图片
发布一个文章摘要
发布一个图片到一个相册

10、例子
POST消息

POST /V4.1/cid-${profileUID}/MyActivities HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
Content-Type: application/json
Accept: application/json
Authorization: WRAP access_token=${ACCESS_TOKEN}
Transfer-Encoding: chunked
Host: apis.live.net
Connection: Keep-Alive
{“__type”:”AddArticleActivity:http://schemas.microsoft.com/ado/2007/08/dataservices”,”ActivityVerb”:”http://activitystrea.ms/schema/1.0/post”,”ApplicationLink”:”http://www.15157.com”,”ActivityObjects”:[{“ActivityObjectType”:”http://activitystrea.ms/schema/1.0/article”,”AlternateLink”:”http://www.15157.com”,”PermaLink”:”http://www.15157.com”,”Title”:”就这样被你征服了1″,”Summary”:”这是一个发布文章的活动1″}]}

复制代码返回

HTTP/1.1 201 Created
Cache-Control: no-cache
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: application/json
Content-Location: http://apis.live.net/V4.1/cid-ec6f634b2a64724a/MyActivities
Location: http://apis.live.net/V4.1/cid-EC6F634B2A64724A/MyActivities/AAAACAETKRLIF3DPMNFSUZDSJI
X-HTTP-Live-Request-Id: [28b4e09b-9c86-4b7d-ab65-b1d83db54ea1::]
X-HTTP-Live-Server: BY2WLC1074115
Date: Sun, 27 Mar 2011 10:02:01 GMT

{“__type”:”AddArticleActivity:http:\/\/schemas.microsoft.com\/ado\/2007\/08\/dataservices”,”Id”:”urn:uuid:AAAACAETKRLIF3DPMNFSUZDSJI”,”SelfLink”:”http:\/\/apis.live.net\/V4.1\/cid-EC6F634B2A64724A\/MyActivities\/AAAACAETKRLIF3DPMNFSUZDSJI”,”Title”:”AddArticleActivityResource”,”ActivityActor”:{“ActivityObjectType”:”http:\/\/activitystrea.ms\/schema\/1.0\/person”,”AlternateLink”:”http:\/\/cid-ec6f634b2a64724a.profile.live.com\/”,”Id”:”-1409798983858752950″},”ActivityVerb”:”http:\/\/activitystrea.ms\/schema\/1.0\/post”,”ApplicationLink”:”http:\/\/www.15157.com”,”ActivityObjects”:[{“ActivityObjectType”:”http:\/\/activitystrea.ms\/schema\/1.0\/article”,”Id”:”0e4e5ac2-2c96-4b17-9bd7-3118773351c0″,”PermaLink”:”http:\/\/www.15157.com\/”,”Summary”:”这是一个发布文章的活动1″,”Title”:”就这样被你征服了1″}]}

复制代码AddArticle.json

{“__type”: “AddArticleActivity:http://schemas.microsoft.com/ado/2007/08/dataservices”,
  “ActivityVerb”: “http://activitystrea.ms/schema/1.0/post”,
  “ApplicationLink”: “${ApplicationLink}”,
  “ActivityObjects”: [
    {
      “ActivityObjectType”: “http://activitystrea.ms/schema/1.0/article”,
      “AlternateLink”: “${ApplicationLink}”,
      “PermaLink”: “${ApplicationLink}”,
      “Title”: “就这样被你征服了”,
      “Summary”: “这是一个发布文章的活动”
    }
  ]
}

复制代码参考资料

http://msdn.microsoft.com/en-us/library/ff750442.aspx 开始
http://msdn.microsoft.com/en-us/library/ff751578.aspx Creating an Activity and Posting it to Your Activity Stream
http://msdn.microsoft.com/en-us/library/ff748442.aspx Collection Level Operations
http://msdn.microsoft.com/en-us/library/ff748607.aspx Using the REST API Service (Messenger Connect)
http://msdn.microsoft.com/en-us/library/ff747750.aspx Resource Model Reference
http://msdn.microsoft.com/en-us/library/ff747597.aspx Resource Model Overview
http://msdn.microsoft.com/en-us/library/ff750702.aspx Posting Activities in JSON Examples
http://msdn.microsoft.com/en-ca/library/ff749529.aspx Messenger Connect Scopes 
http://msdn.microsoft.com/en-us/library/ff749458.aspx Windows Live Messenger Connect
http://msdn.microsoft.com/en-us/library/ff747879.aspx Messenger Connect Resource Model
http://msdn.microsoft.com/en-us/library/gg430655.aspx Send Invitations
http://msdn.microsoft.com/en-us/library/gg251990.aspx Windows Live Messenger Connect Developer Guide

http://activitystrea.ms/head/json-activity.html Activity 的json格式定义
http://activitystrea.ms/schema/1.0/activity-schema-01.html    Activity 的schema定义

http://www.windowslive.cn/mc/ Windows Live Messenger Connect 介绍
http://archive.msdn.microsoft.com/messengerconnect  Windows Live Messenger Connect demo示例下载

常见错误
http://social.msdn.microsoft.com … 2-9a95-ded4366b29be 
http://social.msdn.microsoft.com … 7-b4a6-860e135b63d2 
http://social.msdn.microsoft.com … a-a485-3337814609fb
https://manage.dev.live.com/ 申请live开发app

http://rex.mslivelabs.com/ 
http://open.t.sina.com.cn/wiki/index.php/Oauth sina关于Oauth的介绍
http://oauth.net/code/ oauth的代码

 

1)在这里下载一个java的demo
http://archive.msdn.microsoft.com/messengerconnect
2)在这里看发布活动的例子
http://msdn.microsoft.com/en-us/library/ff750702.aspx

http://code.google.com/p/windows-live-messenger-connect

 

转载请注明:夜阑小雨 » MSN登陆第三方网站 Windows Live Messager Connect 开发介绍

喜欢 (0)or分享 (0)
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址