<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          django-taobaodjango淘寶API插件

          聯(lián)合創(chuàng)作 · 2023-10-02 06:18

          django 應(yīng)用的淘寶API 插件, 實(shí)在覺(jué)得淘寶官方的不好用, 用 django-taobao插件可快速讓django項(xiàng)目調(diào)用淘寶API

          安裝

          pip install django-taobao

          配置

          目前我將淘寶授權(quán)的代碼貢獻(xiàn)到了 python social auth. 所以授權(quán)是需要安裝 python_social_auth并且簡(jiǎn)單配置 django的settings.py:

          INSTALLED_APPS = (
              ...
              'django_taobao',
              'django_social_auth.apps.django_app.default',
          )
          
          AUTHENTICATION_BACKENDS = [
              'social.backends.taobao.TAOBAOAuth',
          ]
          
          SOCIAL_AUTH_TAOBAO_KEY = 'your client id'
          SOCIAL_AUTH_TAOBAO_SECRET = 'your app secret'
                TAOBAO_API_URL ='https://gw.api.tbsandbox.com/router/rest'

          把 social_auth 加入到 你的 urls.py:

          url(r'^taobao/', include('taobao.urls')), # this is taobao api example
          url('', include('social.apps.django_app.urls', namespace='social')), # this is for auth

          現(xiàn)在可以到 youhost.com/login/taobao 登陸 并取到token

          使用 API

          有了token以后, 就可以使用API了. 代碼里的 view.py其實(shí)就是個(gè)例子:

          def user_info(request):
                    print request.user.id
                    user = get_object_or_404(UserSocialAuth.objects.filter(provider='taobao'),user=request.user)
                    token = user.extra_data['access_token']
                    t = TaoBao()
                    t.setParams(access_token=token, method='taobao.user.seller.get')
                    t.setFields('nick,sex')
                    return render_to_response("taobao/index.html", RequestContext(request, {'seller':t.fetch()}))
          瀏覽 28
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  人成视频在线免费观看 | 中文字幕精品视频 | 尻屄视频在线免费看 | 看a片网址| 亚洲电影在线观看 |