PHP code example of dspurl / taobaosdk

1. Go to this page and download the library: Download dspurl/taobaosdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dspurl / taobaosdk example snippets


'providers' => [
	...
	Dspurl\Taobaosdk\TaobaosdkServiceProvider::class,
	...
]
'aliases' => [
	...
	'Taobaosdk' => Dspurl\Taobaosdk\Facades\Taobaosdk::class
	...
]

return [
    'appkey' => '淘宝客appkey',
    'secretKey' => '淘宝客secretKey',
    'adzoneId' => '推广位id',	//mm_xx_xx_xx pid三段式中的第三段。adzone_id需属于appKey拥有者
    'platform' => 2,	//链接形式:1:PC,2:无线,默认:1
];

Route::get('/test','TestController@test');


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Taobaosdk;
class TestController extends Controller
{
    public function test(Request $request){
        // $data=Taobaosdk::TbkItemRecommendGetRequest(558044672087);   //商品关联推荐
        // $data=Taobaosdk::TbkActivitylinkGetRequest(1570638662450,197164077); //官方活动转链
        // $data=Taobaosdk::TbkDgOptimusMaterialRequest(3756);  //物料精选
        // $data=Taobaosdk::TbkDgMaterialOptionalRequest('女装');   //物料搜索
        // $data=Taobaosdk::TbkContentGetRequest(1);    //图文内容输出
        // $data=Taobaosdk::TbkShopGetRequest('女装'); //店铺搜索
        // $data=Taobaosdk::TbkItemInfoGetRequest('562551658548'); //获取商品详情
        // $data=Taobaosdk::TbkSpreadGetRequest('https://s.click.taobao.com/eptgOyv'); //长链转短链
        // print_r($data);
        // exit;
    }
}
shell
php artisan vendor:publish --provider="Dspurl\Taobaosdk\TaobaosdkServiceProvider"