开发者平台信息应用申请

一、开放平台

1.web端

(1)淘宝开放平台

http://open.taobao.com/

注册淘宝账号,关联实名认证的支付宝账号,并进行实人认证

3f1c3c0db773b470dadfb0fff31c33e04b2.jpg

在控制台-服务发布中点击创建新应用

4b5ef39c9efe1844e1c8dc25b7b7d7b7ada.jpg

选择需要的应用标签,进行申请,这里以百川无线应用为例

申请时,会让注册百川账号,进行内容迁移

79c28649cd62e0891ee9209e29b20640b08.jpg

进入阿里百川,创建应用,app地址最好写正式的,不然后面还要重新下载

515c41286b3495469a0f88a497738adbd16.jpg

点击左侧的API申请,选择刚创建的应用

48a569f2d137ba4b7839081448c559c46f7.jpg

点击我的产品后台-开通百川电商sdk和云账号

cad8e32efba06cb3559028540b2b0b11957.jpg

这时返回淘宝开发者平台-应用管理,就能看到相应信息

7a90c83b7d394cac173af504ecce19f28cd.jpg

点击应用管理-设置回调地址

http://127.0.0.1:8000/login/taobao-t

已经获得app_key和app_secret

2cc4fefde5b6add7336a240d1f6b98fddf6.jpg

点击sdk下载,解压(本项目中采用的是social_django三方登录库,不用这一步)

3d855e3153f7bdcf5edca0e00a08ef332cc.jpg

三方设置——阿里百川文档:https://www.kancloud.cn/moxiuxun/taoke_app/709080

 

2.移动应用

(1)QQ互联

234be73d17fae5024a61477f2a303359650.jpg

已经创建过网站应用的,在移动应用里点击关联腾讯开放平台

98fd4c0bb20c9e0b92cec5f1204c3b95c13.jpg

填写网站应用的AppID和AppKey

 

未完,待续

 

二、问题解决

1.三方平台中如果username/nickname为中文时,用django自带的用户模型存储,会出现不规则乱码,影响使用

d284994d7f27cd77ea53bd407b86ec40326.jpg

解决思路:Django-1.10支持中文用户注册登录

0456d0f8c426a8f0e3a46b4e3ed6fe77a81.jpg

找到自定义用户模型扩展继承的AbstractUser类

bab478edff30a772c87b58287f4ea4ae675.jpg

位置:虚拟环境下\Lib\site-packages\django\contrib\auth\models.py

说明:six.PY3 返回一个表示当前运行环境是否为python3的boolean值

发现调用了两个大类:UnicodeUsernameValidator和ASCIIUsernameValidator

8e00ebe328613a4bc2bdc1f170ba5e74605.jpg

进入UnicodeUsernameValidator类

a9e56988f11236b7da311219f166626a519.jpg

3027d0f9c5b1833dc16a9c29cf433e8bdc7.jpg

修改定义的规则

regex = r'^[\S.@+-]+$'

 

三、开放平台文档/接口工具

1.平台文档

微博:https://open.weibo.com/wiki/%E5%BE%AE%E5%8D%9AAPI

QQ:http://wiki.open.qq.com/wiki/%E3%80%90QQ%E7%99%BB%E5%BD%95%E3%80%91%E6%96%87%E6%A1%A3%E8%B5%84%E6%BA%90

微信:https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&lang=zh_CN

(需要审核才能申请开通调用用户信息接口-挺麻烦的)

淘宝:http://open.taobao.com/doc.htm?docId=102635&docType=1

百度:http://developer.baidu.com/wiki/index.php?title=docs/oauth

github:https://developer.github.com/v3/oauth_authorizations/

开源中国:https://www.oschina.net/openapi/docs

蚂蚁金服:https://openhome.alipay.com/developmentDocument.htm

优酷土豆:https://doc.open.youku.com/?docid=483

爱奇艺:http://open.iqiyi.com/

 

 

2.接口管理工具

eoLinker:[https://www.eolinker.com]( https://s.growingio.com/gNKZYz),必须说的是 eoLinker 开源免费的。

一些产品的开源项目和链接:
开源支持:[https://www.eolinker.com/#/os/download]( https://www.eolinker.com/#/os/download)
Github:[https://github.com/eolinker]( https://github.com/eolinker)
码云:[https://gitee.com/eoLinker-API-Management]( https://gitee.com/eoLinker-API-Management)
Coding:[https://coding.net/u/eolinker/project]( https://coding.net/u/eolinker/project)
Blog:[http://blog.eolinker.com]( http://blog.eolinker.com )
视频教程:[http://blog.eolinker.com/#/course/]( http://blog.eolinker.com/#/course/)

 

3.其他文档

1. 微信硬件设备开发文档: http://iot.weixin.qq.com/index.html

2. 微信-蓝牙开发demo: http://iot.weixin.qq.com/document-4_1.html

3. 申请微信公众平台接口测试账号: http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login

4. 微信公众平台开发文档: http://mp.weixin.qq.com/wiki/home/index.html

5. 微信JS-SDK开发的Demo: http://demo.open.weixin.qq.com/jssdk/

6. 微信JS-SDK开发文档: http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html

 

四、social_django添加三方登录代码

1.百度

# coding:utf-8
"""
注意:登录可成功,退出时 清除session还是有残留信息
Baidu OAuth2 backend, docs at:
    http://developer.baidu.com/wiki/index.php?title=docs/oauth
"""
from .oauth import BaseOAuth2
class BaiduOAuth2(BaseOAuth2):
    """Baidu OAuth authentication backend"""
    name = 'baidu'
    ID_KEY = 'uid'
    AUTHORIZATION_URL = 'http://openapi.baidu.com/oauth/2.0/authorize'
    ACCESS_TOKEN_URL = 'https://openapi.baidu.com/oauth/2.0/token'
    ACCESS_TOKEN_METHOD = 'POST'
    REDIRECT_STATE = False
    EXTRA_DATA = [
        ('userid', 'userid'),
        ('username', 'username'),
        ('portrait', 'portrait'),
        ('sex', 'sex')
    ]

    def get_user_details(self, response):
        """Return user details from Baidu.
        """
        username = response.get('username')
        return {'username': username,
                'first_name': username}

    def get_uid(self, access_token):
        """Return uid by access_token"""
        data = self.get_json(
            'https://openapi.baidu.com/rest/2.0/passport/users/getLoggedInUser',
            method='POST',
            params={'access_token': access_token}
        )
        return data['uid']

    def user_data(self, access_token, *args, **kwargs):
        uid = self.get_uid(access_token)
        response = self.get_json(
            'https://openapi.baidu.com/rest/2.0/passport/users/getInfo', params={
                'access_token': access_token,
            }
        )
        response['uid'] = uid
        return response

baidu.py

2.淘宝修改

# 自定义补充
class TAOBAOAuth2(BaseOAuth2):
    """Taobao OAuth authentication mechanism"""
    name = 'taobao'
    ID_KEY = 'taobao_open_uid'

    ACCESS_TOKEN_METHOD = 'POST'
    AUTHORIZATION_URL = 'https://oauth.taobao.com/authorize'
    ACCESS_TOKEN_URL = 'https://oauth.taobao.com/token'

    EXTRA_DATA = [
        ('taobao_user_id', 'taobao_user_id'),
        ('taobao_user_nick', 'taobao_user_nick'),
        ('access_token', 'access_token'),
        ('token_type', 'token_type')
    ]

    def user_data(self, access_token, *args, **kwargs):
        """Return user data provided"""
        try:
            return self.get_json('http://gw.api.taobao.com/router/rest', params={
                'method': 'taobao.user.get',
                'fomate': 'json',
                'v': '2.0',
                'access_token': access_token
            })
        except ValueError:
            return None

    def get_user_details(self, response):
        """Return user details from Taobao account"""
        fullname, first_name, last_name = self.get_user_names(
            response.get('name')
        )
        username = response.get('taobao_user_nick')
        return {
            'username': username,
            'first_name': first_name,
        }

taobao.py

说明:

调用环境服务地址(HTTP)服务地址(HTTPS)
沙箱环境http://gw.api.tbsandbox.com/router/resthttps://gw.api.tbsandbox.com/router/rest
正式环境http://gw.api.taobao.com/router/resthttps://eco.taobao.com/router/rest
海外环境http://api.taobao.com/router/resthttps://api.taobao.com/router/rest

3.开源中国

# coding:utf-8
"""
Oschina OAuth2 backend, docs at:
    https://www.oschina.net/openapi/docs
"""
from .oauth import BaseOAuth2

class OschinaOAuth2(BaseOAuth2):
    """Oschina OAuth authentication backend"""
    name = 'oschina'
    ID_KEY = 'uid'
    AUTHORIZATION_URL = 'https://www.oschina.net/action/oauth2/authorize'
    ACCESS_TOKEN_URL = 'https://www.oschina.net/action/openapi/token'
    ACCESS_TOKEN_METHOD = 'POST'
    REDIRECT_STATE = False
    EXTRA_DATA = [
        ('name', 'username'),
        ('portrait', 'portrait'),
        ('gender', 'gender')
    ]

    def get_user_details(self, response):
        """Return user details from Oschina.
        """
        username = response.get('name')
        return {'username': username,
                'first_name': username}

    def user_data(self, access_token, response=None, *args, **kwargs):
        """Return user data"""
        user_data = self.get_json(
            'https://www.oschina.net/action/openapi/my_information',
            params={'access_token': access_token}
        )
        return user_data

 

 

五、参考文档:

1.Django-1.10支持中文用户注册登录:https://www.cnblogs.com/dribs/p/8376040.html

2.求推荐一个开源的 API 文档管理系统:https://www.v2ex.com/t/106648

3.bilibili开放平台相关:https://www.helplib.com/c/mutia_127096

转载于:https://my.oschina.net/u/3018050/blog/2996136

Python网络爬虫与推荐算法新闻推荐平台:网络爬虫:通过Python实现新浪新闻的爬取,可爬取新闻页面上的标题、文本、图片、视频链接(保留排版) 推荐算法:权重衰减+标签推荐+区域推荐+热点推荐.zip项目工程资源经过严格测试可直接运行成功且功能正常的情况才上传,可轻松复刻,拿到资料包后可轻松复现出一样的项目,本人系统开发经验充足(全领域),有任何使用问题欢迎随时与我联系,我会及时为您解惑,提供帮助。 【资源内容】:包含完整源码+工程文件+说明(如有)等。答辩评审平均分达到96分,放心下载使用!可轻松复现,设计报告也可借鉴此项目,该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的。 【提供帮助】:有任何使用问题欢迎随时与我联系,我会及时解答解惑,提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 【项目价值】:可用在相关项目设计中,皆可应用在项目、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面,可借鉴此优质项目实现复刻,设计报告也可借鉴此项目,也可基于此项目来扩展开发出更多功能 下载后请首先打开README文件(如有),项目工程可直接复现复刻,如果基础还行,也可在此程序基础上进行修改,以实现其它功能。供开源学习/技术交流/学习参考,勿用于商业用途。质量优质,放心下载使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值