Taobao Guest API Component Upgrade Adjustment method Introduction

Source: Internet
Author: User
Tags setcookie

Popular talk is the integration and use of JSSDK.
JSSDK's official explanation:
Taobao JSSDK is based on JavaScript SDK, the site by introducing a JS file can be achieved:
Use JavaScript to access Taobao APIs securely and conveniently via JSSDK.
Through the JSSDK provides the component method, the quick, the simple integration Taobao electric quotient component.
The only access to higher-security services, such as the association recommendation for user Behavior in association recommendations, the Favorites interface, and so on.
Cooperative website does not need a strong back-end service system, through the front-end to obtain data and direct display, can get "small input to support a large number of users" effect.
Provide multi-dimensional user data Analysis service for the cooperative website.
The JSSDK Integration of PHP pages
Using a PHP program such as WordPress, the owner of the site is still very helpful this time,
Because the official document is the use of PHP document integration Jssdk to illustrate.
1. Load the Jssdk file in the page
One of the appkey=xxxxxxx behind the xxxxx is your Appkey

The code is as follows Copy Code

<script src= "Http://l.tbcdn.cn/apps/top/x/sdk.js?appkey=xxxxxxx" ></script>

2. Generate signature, deposit in cookie

The code is as follows Copy Code

<?php
$app _key = ' xxxxxxx ';/* Fill in Appkey * *
$secret = '/* Fill in appsecret ' * *
$timestamp =time (). " 000 ";
string concatenation required for signature
$message = $secret. ' App_key '. $app _key. ' Timestamp '. $timestamp. $secret;
Get signature
$mysign =strtoupper (Hash_hmac ("MD5", $message, $secret));
Deposit time Stamp
Setcookie ("timestamp", $timestamp);
Deposit Signature
Setcookie ("sign", $mysign);
?>

Taobao Guest Interface Calls

Here's an example of the simplest, official call interface

  code is as follows copy code

Top.api (' rest ' , ' get ', {
   method: ' Taobao.taobaoke.widget.items.convert ',
    track_iids: ' 19237740785_track_11116 ',
   fields: ' Num_iid,click_url,commission_rate '
 },function (resp) {
   if (resp.error_response) {
     alert (' Taobao.taobaoke.widget.items.convert interface to get quotient information product failed! ' +RESP.ERROR_RESPONSE.MSG);
      return false;
    }
     var Respitem=resp.taobaoke_items.taobaoke_item;
     for (var i=0;i<respitem.length;i++) {
     //$ ("#r" + RESPITEM[I].NUM_IID). HTML ("commission:" +number (respitem[i].commission_rate)/100+ "%");
     //$ ("#a" +respitem[i].num_iid). attr ("href", respitem[i].click_url);
     }
 })

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.