C#模拟移动端weibosdk登录APP应用

项目进展:现已可以通过微博sdk登录三方应用

C#模拟移动端weibosdk登录APP应用_第1张图片

 

运行效果:

C#模拟移动端weibosdk登录APP应用_第2张图片

1Authorize请求

GET https://open.weibo.cn/oauth2/authorize?client_id=608714079&redirect_uri=http%3A%2F%2Fwww.xiaohongshu.com%2F&scope=all&response_type=code&version=0031405000&packagename=com.xingin.xhs&key_hash=6cfca61d9d1eca56844806706ba18cf7 HTTP/1.1

Host: open.weibo.cn

Connection: keep-alive

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

User-Agent: Mozilla/5.0 (Linux; Android 4.4.4; ZUK Z2121 Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Safari/537.36

Accept-Encoding: gzip,deflate

Accept-Language: zh-CN,en-US;q=0.8

X-Requested-With: com.xingin.xhs

参数列表

client_id 608714079 //小红书weibo oath client_id

redirect_uri http://www.xiaohongshu.com/

scope all

response_type  code

version 0031405000

packagename com.xingin.xhs

key_hash 6cfca61d9d1eca56844806706ba18cf7 //apk CERT.RSA文件md5hash

如果Authorize失败,返回302

 

2、在执行跳转前执行前置方法 ClientCommonConfig

 

ClientCommonConfig请求

GET http://api.weibo.cn/2/client/common_config?appkey=608714079&packagename=com.xingin.xhs&key_hash=6cfca61d9d1eca56844806706ba18cf7&version=0031405000&oauth_timestamp=1508989219&oauth_sign=c22eb2c HTTP/1.1

X-Tingyun-Processed: true

X-Tingyun-Id: LbxHzUNcfig;c=2;r=565931765

Host: api.weibo.cn

Connection: Keep-Alive

 

参数列表

appkey 608714079

packagename com.xingin.xhs

key_hash 6cfca61d9d1eca56844806706ba18cf7

version 0031405000

oauth_timestamp 1508989219

oauth_sign c22eb2c

 

ClientCommonConfig响应

HTTP/1.1 200 OK

Server: Tengine/2.2.0

Date: Thu, 26 Oct 2017 03:40:19 GMT

Content-Type: application/json;charset=UTF-8

Connection: close

Vary: Accept-Encoding

X-Powered-By: PHP/7.0.15

X-Log-Uid:

X-Error-Code: 0

X-Validator: eaG4t1TR+piBrjEL8VbZKX3yr2vBURkjoNHe+GdK3rk=

PROC_NODE: v5-web-007.mweibo.xxg.intra.weibo.cn

SSL_NODE: ssl-010.mweibo.yf.intra.weibo.cn

Content-Length: 472

 

u7FFIamNkcuNHMwmAa+VaBLCV5OXWYPQOP+foSfZjYyxZGpn3KZknFVy4ErIXpjcrTepq2dyvmshHzKaHQSXb9cK5ndukrs0n1wuvQ1QN+v847terBC12nEm1k/oRDbcP2veR7Zrj2k+bPItUJ9Qg5xdPIIbfRCMuXUGRCy6t09vhILzRYQLBSpfO5NUbfXr13wEjZdivmeBmFOZihCeFioZgAU6bJ15lqNeHwEZCcosvJUosQr+UIDaJtfk3WUUnzELTZeV+mxiSBXJFCQ2SFa8PjY9al0rwizH7IZqWJf7wZk/95v6dkGFbhHVfwBSw3QyAlZNWQsF/meeatj599oREW6IUu/BYwjJhb4JmMSk+FfVnyJuHB9exTdCepmXgyQ4w1f0+psrEZ/NYoA8JJji3F6pDsDN/qY8/fvzzy2sXgKz19gJ69oJWkM4r+tWG/1iwg1AnhDu1RqKQxt7Tw==

 

内容需要Aes解密,解密后得到JSON对象

{

    "cmd": {

        "app_install": [

            {

                "app_package": "",

                "app_sign": "18da2bf10352443a00a5e046d9fca6bd",

                "app_version": "1762",

                "download_url": "",

                "notification_delay": "",

                "notification_text": "",

                "notification_title": ""

            }

        ],

        "app_invoke": [

            {

                "notification_delay": "",

                "notification_text": "",

                "notification_title": "",

                "package": "",

                "scheme": "",

                "url": ""

            }

        ],

        "frequency": ""

    }

}

 

3、接下来执行302跳转,加载页面

GET https://passport.weibo.cn/signin/login?client_id=608714079&redirect_uri=http://www.xiaohongshu.com/&display=sdk&action=login&offcialMobile=true&rf=1&version=0031405000&sso_type=1&scope=all HTTP/1.1

Host: passport.weibo.cn

Connection: keep-alive

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

User-Agent: Mozilla/5.0 (Linux; Android 4.4.4; ZUK Z2121 Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Safari/537.36

Accept-Encoding: gzip,deflate

Accept-Language: zh-CN,en-US;q=0.8

X-Requested-With: com.xingin.xhs

 

参数列表

client_id 608714079

redirect_uri http://www.xiaohongshu.com/

display sdk

action login

offcialMobile true

rf 1

version 0031405000

sso_type 1

scope all

 

在跳转之前发起一个请求GetAid

4GetAid请求

GET https://api.weibo.com/oauth2/getaid.json?appkey=608714079&mfp=01jGbGZnVv%2BnKgEFKn%2BgdgAAF7Sb%2BoXqJOLk2iVcI5BlDy%2F6QpcBmg2Gu0e7KaKW5zByD2CkW0uUuNFjOl%2BgyukhYo0w2gi%2FJ9A22QNXKChyKsefPLxD4oxzc%2BZ%2ByAM4z%2FJVCobjKN5mq9mSmX9DSwCTiJZ%2FFQ%2FdLG3DlChTJXQSlL2nB6sNQH1TEMPlAg73NB64ZV02nPiZFj9i4JFZefKHdGV4%2BvNYjkZ9KZCmSRJOsW73%2BH4SleNRgyh%2B0O%2FUYRDV%2Fhld9k2ygGiV8rq54dvDvv8oLOg37CflmpySgsC%2FOFew1POaj0YPlOdzDhFiwEDLbQoz4raHqDLtHX%2FSzJaUKuiUUdGun6SfgE%2F34WxrvNnVPUxv2iaZ3z8NmCOIzQ47dTfT2PcdZ7x0SZTX4b4pkpTBh2wM8iSmEVmjsvaQUnZxrp29tJtoAPm2en0Kua6RxO7wCD5rAUsCN3WlUTcgTxzVsOaKmbIiDUOizUz9AARCuA3bRiF2nTmzwbkEAZTHlwyJ%2Fhl%2Fv6x5HFHxVU0rXxz2WFRtAJ2W2XoCZ7VndIh1cjL%2FKIU05u74lKtOOU09GbU%2BMIQAstm4CA5WxKZ85X1wODH8TOifT44pHsNXuZrJ3cyPrznC3HFJZSWiSp0Rg9Z5BNmf%2Bcg%2B%2FbWVScGeeKKp%2FZTx%2B8ufjwZJNHuDE%3D&packagename=com.xingin.xhs&key_hash=6cfca61d9d1eca56844806706ba18cf7&oauth_timestamp=1508989219&oauth_sign=c22eb2c HTTP/1.1

X-Tingyun-Processed: true

X-Tingyun-Id: LbxHzUNcfig;c=2;r=39933382

Host: api.weibo.com

Connection: Keep-Alive

 

参数列表

appkey 608714079

mfp 01jGbGZnVv+nKgEFKn+gdgAAF7Sb+oXqJOLk2iVcI5BlDy/6QpcBmg2Gu0e7KaKW5zByD2CkW0uUuNFjOl+gyukhYo0w2gi/J9A22QNXKChyKsefPLxD4oxzc+Z+yAM4z/JVCobjKN5mq9mSmX9DSwCTiJZ/FQ/dLG3DlChTJXQSlL2nB6sNQH1TEMPlAg73NB64ZV02nPiZFj9i4JFZefKHdGV4+vNYjkZ9KZCmSRJOsW73+H4SleNRgyh+0O/UYRDV/hld9k2ygGiV8rq54dvDvv8oLOg37CflmpySgsC/OFew1POaj0YPlOdzDhFiwEDLbQoz4raHqDLtHX/SzJaUKuiUUdGun6SfgE/34WxrvNnVPUxv2iaZ3z8NmCOIzQ47dTfT2PcdZ7x0SZTX4b4pkpTBh2wM8iSmEVmjsvaQUnZxrp29tJtoAPm2en0Kua6RxO7wCD5rAUsCN3WlUTcgTxzVsOaKmbIiDUOizUz9AARCuA3bRiF2nTmzwbkEAZTHlwyJ/hl/v6x5HFHxVU0rXxz2WFRtAJ2W2XoCZ7VndIh1cjL/KIU05u74lKtOOU09GbU+MIQAstm4CA5WxKZ85X1wODH8TOifT44pHsNXuZrJ3cyPrznC3HFJZSWiSp0Rg9Z5BNmf+cg+/bWVScGeeKKp/ZTx+8ufjwZJNHuDE= 

Mfpmachine full parameters?)是rsa加密的设备信息JSON字串,包括(os+imei+meid+imsi+mac+iccid+seriaNo+androidId+cpu+model+sdsize+resolution+ssid+deviceName+connectType+uaaid

packagename com.xingin.xhs

key_hash 6cfca61d9d1eca56844806706ba18cf7

oauth_timestamp 1508989219

oauth_sign c22eb2c

 

响应内容

{"aid":"01AmjYJZon83qXRbP3-X-LU9kpCO0n1K7BmDtG1tbuvec85tQ."}

Aid将被存储,以后存储有Aid值将不再发送该请求

 

接下来通过网页加载weibo登录页面,输入账号密码登录。登录成功在授权页面点击确定授权

 

确定授权,这一步由浏览器自动完成

POST https://open.weibo.cn/oauth2/authorize HTTP/1.1

Host: open.weibo.cn

Connection: keep-alive

Content-Length: 245

Cache-Control: max-age=0

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

Origin: https://passport.weibo.cn

User-Agent: Mozilla/5.0 (Linux; Android 4.4.4; ZUK Z2121 Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Safari/537.36

Content-Type: application/x-www-form-urlencoded

Referer: https://passport.weibo.cn/signin/login?client_id=608714079&redirect_uri=http://www.xiaohongshu.com/&display=sdk&action=login&offcialMobile=true&rf=1&version=0031405000&sso_type=1&scope=all

Accept-Encoding: gzip,deflate

Accept-Language: zh-CN,en-US;q=0.8

X-Requested-With: com.xingin.xhs

 

client_id=608714079&redirect_uri=http%3A%2F%2Fwww.xiaohongshu.com%2F&display=sdk&action=login&offcialMobile=true&rf=1&version=0031405000&sso_type=1&scope=all&wm=3349&ticket=ST-NjM1OTM1NzQxOA%3D%3D-1508990187-tc-14FE7791A2547A8A0F3F03CE5521C8F2-1

 

参数列表

client_id 608714079

redirect_uri http://www.xiaohongshu.com/

display sdk

action login

offcialMobile true

rf 1

version 0031405000

sso_type 1

scope all

wm 3349

ticket ST-NjM1OTM1NzQxOA==-1508990187-tc-14FE7791A2547A8A0F3F03CE5521C8F2-1

 

再次调用oauth2/Authorize方法,这次是跳转到目标站,weibo登录完成。

POST https://open.weibo.cn/oauth2/authorize HTTP/1.1

Host: open.weibo.cn

Connection: keep-alive

Content-Length: 602

Cache-Control: max-age=0

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

Origin: https://open.weibo.cn

User-Agent: Mozilla/5.0 (Linux; Android 4.4.4; ZUK Z2121 Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Safari/537.36

Content-Type: application/x-www-form-urlencoded

Referer: https://open.weibo.cn/oauth2/authorize

Accept-Encoding: gzip,deflate

Accept-Language: zh-CN,en-US;q=0.8

Cookie: JSESSIONID=A7744F796A83D087FBA9880ED45A48B9

X-Requested-With: com.xingin.xhs

 

display=sdk&action=scope&scope=follow_app_official_microblog&withOfficalFlag=0&withOfficalAccount=null&response_type=code®Callback=https%253A%252F%252Fopen.weibo.cn%252F2%252Foauth2%252Fauthorize%253Fclient_id%253D608714079%2526response_type%253Dcode%2526display%253Dsdk%2526redirect_uri%253Dhttp%25253A%25252F%25252Fwww.xiaohongshu.com%25252F%2526from%253D%2526with_cookie%253D&redirect_uri=http%3A%2F%2Fwww.xiaohongshu.com%2F&client_id=608714079&appkey62=YAyVF&state=&from=&offcialMobile=true&uid=6359357418&url=&verifyToken=b7e529c991906f6911ad621de267c45a&visible=0&version=0031405000&sso_type=1

参数列表

display sdk

action scope

scope follow_app_official_microblog

withOfficalFlag 0

withOfficalAccount null

response_type code

regCallback https%3A%2F%2Fopen.weibo.cn%2F2%2Foauth2%2Fauthorize%3Fclient_id%3D608714079%26response_type%3Dcode%26display%3Dsdk%26redirect_uri%3Dhttp%253A%252F%252Fwww.xiaohongshu.com%252F%26from%3D%26with_cookie%3D

redirect_uri http://www.xiaohongshu.com/

client_id 608714079

appkey62 YAyVF

state

from

offcialMobile true

uid 6359357418

url

verifyToken b7e529c991906f6911ad621de267c45a

visible 0

version 0031405000

sso_type 1

响应内容 302

http://www.xiaohongshu.com/?access_token=2.00w3N4wG0B2GMf43ca4b5de2aPvs_E&remind_in=2646209&expires_in=2646209&refresh_token=2.00w3N4wG0B2GMf0bc4272fb04dsQrC&uid=6359357418&scope=follow_app_official_microblog

 

获取weibo用户信息

GET https://api.weibo.com/2/users/show.json?uid=6359357418&access_token=2.00w3N4wG0B2GMf43ca4b5de2aPvs_E&aid=01AmjYJZon83qXRbP3-X-LU9kpCO0n1K7BmDtG1tbuvec85tQ.&oauth_timestamp=1508990190&oauth_sign=a54bf9b HTTP/1.1

X-Tingyun-Processed: true

X-Tingyun-Id: LbxHzUNcfig;c=2;r=1187104192

Host: api.weibo.com

Connection: Keep-Alive

 

参数列表

uid 6359357418

access_token 2.00w3N4wG0B2GMf43ca4b5de2aPvs_E

aid 01AmjYJZon83qXRbP3-X-LU9kpCO0n1K7BmDtG1tbuvec85tQ.

oauth_timestamp 1508990190

oauth_sign a54bf9b

 

响应内容

{

    "id": 6359357418,

    "idstr": "6359357418",

    "class": 1,

    "screen_name": "思永negative",

    "name": "思永negative",

    "province": "51",

    "city": "6",

    "location": "四川 德阳",

    "description": "",

    "url": "",

    "profile_image_url": "http://tvax3.sinaimg.cn/default/images/default_avatar_male_50.gif",

    "profile_url": "u/6359357418",

    "domain": "",

    "weihao": "",

    "gender": "m",

    "followers_count": 1,

    "friends_count": 60,

    "pagefriends_count": 0,

    "statuses_count": 0,

    "favourites_count": 0,

    "created_at": "Wed Sep 06 14:10:30 +0800 2017",

    "following": false,

    "allow_all_act_msg": false,

    "geo_enabled": true,

    "verified": false,

    "verified_type": -1,

    "remark": "",

    "insecurity": {

        "sexual_content": false

    },

    "ptype": 0,

    "allow_all_comment": true,

    "avatar_large": "http://tvax3.sinaimg.cn/default/images/default_avatar_male_180.gif",

    "avatar_hd": "http://tvax3.sinaimg.cn/default/images/default_avatar_male_180.gif",

    "verified_reason": "",

    "verified_trade": "",

    "verified_reason_url": "",

    "verified_source": "",

    "verified_source_url": "",

    "follow_me": false,

    "like": false,

    "like_me": false,

    "online_status": 0,

    "bi_followers_count": 0,

    "lang": "zh-cn",

    "star": 0,

    "mbtype": 2,

    "mbrank": 1,

    "block_word": 0,

    "block_app": 0,

    "credit_score": 80,

    "user_ability": 0,

    "urank": 0,

    "story_read_state": -1,

    "vclub_member": 0

}

 

小红书登录

POST https://www.xiaohongshu.com/api/sns/v2/user/login HTTP/1.1

User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.4.4; ZUK Z2121 Build/KTU84P) Resolution/720*1280 Version/5.2.1 Build/502001 Device/(ZUK;ZUK Z2121)

Content-Type: application/x-www-form-urlencoded

Content-Length: 585

Host: www.xiaohongshu.com

Connection: Keep-Alive

Accept-Encoding: gzip

 

android_id=3024047621650843&nickname=%E6%80%9D%E6%B0%B8negative&token=2.00w3N4wG0B2GMf43ca4b5de2aPvs_E&imei=861032536407241&imageb=http%3A%2F%2Ftvax3.sinaimg.cn%2Fdefault%2Fimages%2Fdefault_avatar_male_180.gif&tokenExireTime=1970-01-01%2008%3A00%3A00&gender=0&images=http%3A%2F%2Ftvax3.sinaimg.cn%2Fdefault%2Fimages%2Fdefault_avatar_male_180.gif&verifyReason=none&openid=6359357418&type=weibo&verifyType=-1&url=u%2F6359357418&platform=Android&deviceId=87cba87d-e724-3963-acbe-7b8113ed6262&versionName=5.2.1&channel=Store360&lang=zh-CN&t=1508990190&sign=d81c6e0dca7c88c2693527509ce0ca0c

 

参数列表

android_id 3024047621650843

nickname 思永negative

token 2.00w3N4wG0B2GMf43ca4b5de2aPvs_E

imei 861032536407241

imageb http://tvax3.sinaimg.cn/default/images/default_avatar_male_180.gif

tokenExireTime 1970-01-01 08:00:00

gender 0

images http://tvax3.sinaimg.cn/default/images/default_avatar_male_180.gif

verifyReason none

openid 6359357418

type weibo

verifyType -1

url u/6359357418

platform Android

deviceId 87cba87d-e724-3963-acbe-7b8113ed6262

versionName 5.2.1

channel Store360

lang zh-CN

t 1508990190

sign d81c6e0dca7c88c2693527509ce0ca0c

 

签名算法

请联系我索取

 

响应内容

{

    "data": {

        "bstatus": "",

        "comments": 0,

        "desc": "还没有信息耶~",

        "easemob_password": "55fea16f3c3f6cf9ec6f96d57ed6ae17",

        "fans": 0,

        "follows": 0,

        "gender": 0,

        "historyscore": 0,

        "imageb": "https://img.xiaohongshu.com/avatar/59ed588682ec391730ffa604.jpg@160w_160h_92q_1e_1c_1x.jpg",

        "images": "https://img.xiaohongshu.com/avatar/59ed588682ec391730ffa604.jpg@160w_160h_92q_1e_1c_1x.jpg",

        "isgroupmember": false,

        "level": {

            "image": "",

            "name": "无名小薯",

            "number": 0

        },

        "location": "",

        "n_dolikes": 0,

        "nboards": 0,

        "ndiscovery": 0,

        "need_phone": false,

        "need_show_tag_guide": false,

        "need_verify_id": true,

        "new_fans": 0,

        "nickname": "思永negative",

        "nlikes": 0,

        "openid": "6359357418",

        "order_list_link": "http://www.xiaohongshu.com/order/list?sid=1193486191771775896",

        "pokes": 0,

        "red_club": false,

        "red_club_level": 0,

        "redclubscore": 0,

        "register_time": "1508726918",

        "score": 0,

        "sessionid": "session.1193486191771775896",

        "share_link": "http://www.xiaohongshu.com/mobile/profile/index?oid=user.59ed588682ec391730ffa604",

        "token": "2.00w3N4wG0B2GMf43ca4b5de2aPvs_E",

        "type": "weibo",

        "user_exists": true,

        "user_token": "55fea16f3c3f6cf9ec6f96d57ed6ae17",

        "userid": "59ed588682ec391730ffa604"

    },

    "result": 0

}

 

小红书App授权检测

GET https://www.xiaohongshu.com/api/sns/v1/user/me/authority?platform=Android&deviceId=87cba87d-e724-3963-acbe-7b8113ed6262&versionName=5.2.1&channel=Store360&sid=session.1193486191771775896&lang=zh-CN&t=1508990191&sign=2dc825931faa7b4a5ef901e0ad5e8121 HTTP/1.1

Authorization: session.1193486191771775896

User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.4.4; ZUK Z2121 Build/KTU84P) Resolution/720*1280 Version/5.2.1 Build/502001 Device/(ZUK;ZUK Z2121)

Host: www.xiaohongshu.com

Connection: Keep-Alive

Accept-Encoding: gzip

 

参数列表

platform Android

deviceId 87cba87d-e724-3963-acbe-7b8113ed6262

versionName 5.2.1

channel Store360

sid session.1193486191771775896

lang zh-CN

t 1508990191

sign 2dc825931faa7b4a5ef901e0ad5e8121

 

响应内容

{"data":"9cm538gDnOyQ2+7gwjH2Dtpvgx6UWPtbaJw4p28/7hnZUuFabrnC/NFgFIMZ6mIQzWY9KfZbVKNvKSis5VOmI/3vGlPrOPDjNThslTRXMDPHOoGFpdSFTi24i1quArb5","result":0}

 

解密方式

请联系我索取

 

解密内容

{"emoticon_keyboard":false,"is_seller":false,"max_tags_in_post":10,"post_video":true}

 

 

 =================================================================================================

 

打开文章页面:

https://www.xiaohongshu.com/api/sns/v8/note/{noteId}

检查关注

data.user.fstatus:”none”|”follows”

检查点赞:

data.inlikes: true,

检查收藏:

data.infavs: true, 

 

执行关注操作:

POST https://www.xiaohongshu.com/api/sns/v1/user/follow HTTP/1.1

执行点赞操作:

https://www.xiaohongshu.com/api/v1/discovery/like

执行收藏操作:

POST https://www.xiaohongshu.com/api/sns/v1/note/collect HTTP/1.1

 

 关键词:libweibosdkcore.so weibosdk xhs com.xingin.xhs JNIEnv

 

转载于:https://www.cnblogs.com/mrtiny/p/7799313.html

你可能感兴趣的:(C#模拟移动端weibosdk登录APP应用)