创建应用
接入
使用hello.js接入
使用hello.js简化接入,facebook和twitter接入方法一样。
hello.js(***/hello.js/)是一个客户端javascript sdk,用于oauth2认证web服务以及请求它们的rest api。
hellojs标准化了路径,并响应常见的api,比如说google data services、facebook graph以及windows live connect。它们是模块,所以这个列表还在增长中。
// 初始化,配置应用idhello.init({ facebook: facebook_client_id, windows: windows_client_id}, {redirect_uri:'redirect.html'})// 登录hello.on('auth.login', function(auth){ // 登录成功后,获取用户信息(fb、tw的用户数据有区别) hello( auth.network ).api( '/me' ).then(function (res) { console.log(res) })})
facebook登录后获取的用户信息
{ email: "xx@gmail.com", first_name: "xx", id: "123456", last_name: "xx", name: "xx", picture: "url", thumbnail: "url"}
twitter登录后获取的用户信息
{ "id": 123456, "id_str": "123456", "name": "xx", "screen_name": "xx", "location": "", "description": "xx", "url": "url", "entities": { "description": { "urls": [] } }, "protected": false, "followers_count": 0, "friends_count": 0, "listed_count": 0, "created_at": "fri mar 08 03:36:20 0000 2022", "favourites_count": 0, "utc_offset": null, "time_zone": null, "geo_enabled": false, "verified": false, "statuses_count": 0, "lang": "en", "contributors_enabled": false, "is_translator": false, "is_translation_enabled": false, "profile_background_color": "f5f8fa", "profile_background_image_url": null, "profile_background_image_url_https": null, "profile_background_tile": false, "profile_image_url": "url", "profile_image_url_https": "url", "profile_link_color": "1da1f2", "profile_sidebar_border_color": "c0deed", "profile_sidebar_fill_color": "ddeef6", "profile_text_color": "333333", "profile_use_background_image": true, "has_extended_profile": false, "default_profile": true, "default_profile_image": true, "following": false, "follow_request_sent": false, "notifications": false, "translator_type": "none", "suspended": false, "needs_phone_verification": false, "first_name": "xx", "last_name": "", "thumbnail": "url"}
facebook分享
触发分享:
fbshare () { let sharepath = '' // 分享出去之后别人打开的链接 let title = '' // 分享标题 window.open('https://www.facebook.com/sharer/sharer.php?u=' encodeuricomponent(sharepath) '&t=' encodeuricomponent(title), '_blank', 'toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=600, height=450, top=100, left=350')}
分享信息设置:
分享出去的样式包含图片,标题,简介
这些信息不是分享的时候设置的,是爬虫直接爬的分享链接页面head中预先设置好的分享信息,head配置如下
twitter分享
触发分享:
twshare () { let content= '' window.open(`***/share?text=${encodeuricomponent(data.title)}&url=${encodeuricomponent(urlstr)}`, '_blank', 'toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=600, height=450, top=100, left=350')}
分享信息设置:
分享出去的样式包含图片,标题,简介
这些信息不是分享的时候设置的,是爬虫直接爬的分享链接页面head中预先设置好的分享信息,head配置如下
本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。e-mail:dandanxi6@qq.com