PHP code example of xlstudio / hupun
1. Go to this page and download the library: Download xlstudio/hupun 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' );
xlstudio / hupun example snippets
use Xlstudio \Hupun \HupunClient ;
$hupunClient = new HupunClient('填写你申请的 B2C 的 appKey' ,'填写你申请的 B2C 的 appSecret' );
$hupunClient->setGatewayUrl('填写万里牛的 B2C 的 API' );
$hupunClient->setHupunSdkWorkDir('./data/' );
$item['shopNick' ] = '你的店铺昵称' ;
$item['itemID' ] = '商品ID' ;
$item['title' ] = '商品标题' ;
$item['itemCode' ] = '商品编码' ;
$item['price' ] = 100.00 ;
$item['itemURL' ] = '商品地址' ;
$item['imageURL' ] = '图片地址' ;
$item['status' ] = 1 ;
$item['createTime' ] = time() * 1000 ;
$item['modifyTime' ] = time() * 1000 ;
$item['skus' ] = [];
$items[] = $item;
$params['items' ] = json_encode($items);
$result = $hupunClient->execute('items/open' , $params, 'post' );
var_dump($result);
use Xlstudio \Hupun \HupunClient ;
$hupunClient = new HupunClient('填写你申请的 OPEN 的 appKey' ,'填写你申请的 OPEN 的 appSecret' );
$hupunClient->setGatewayUrl('填写万里牛的 OPEN 的 API' );
$hupunClient->setHupunSdkWorkDir('./data/' );
$item['article_number' ] = '货号' ;
$item['item_name' ] = '商品名称' ;
$item['item_code' ] = '商品编码' ;
$item['remark' ] = '商品备注' ;
$item['prime_price' ] = 50.00 ;
$item['sale_price' ] = 100.00 ;
$item['item_pic' ] = '图片地址' ;
$params['item' ] = json_encode($item);
$result = $hupunClient->execute('erp/goods/add/item' , $params, 'post' );
var_dump($result);
use Xlstudio \Hupun \HupunClient ;
$hupunClient = new HupunClient('填写你申请的 B2C 的 appKey' ,'填写你申请的 B2C 的 appSecret' );
$hupunClient->setGatewayUrl('填写万里牛的 B2C 的 API' );
$hupunClient->setHupunSdkWorkDir('./data/' );
$params['shop_type' ] = 100 ;
$params['shop_nick' ] = '你的店铺昵称' ;
$params['item_id' ] = '商品ID' ;
$params['sku_id' ] = '规格ID' ;
$result = $hupunClient->execute('inventories/erp/single' , $params, 'get' );
var_dump($result);