The example in this article describes the way that PHP calls Taobao open API to get the seller's store ID based on the seller's nickname. Share to everyone for your reference. The implementation method is as follows:
<?php header ("Content-type:text/html;charset=utf-8"); * This program function: Root sellers nickname to get sellers store SID, there are shop title * * *//config $appKey = ' 12345678;
Your secret key $appSecret = ' 123456789 '; $usernick = ' Grayvoice '; Your username $salenick = ' water shortage fish ';
Seller Nickname//Signature function createsign ($PARAMARR) {global $appSecret;
$sign = $appSecret;
Ksort ($PARAMARR);
foreach ($paramArr as $key => $val) {if ($key!= ' && $val!= ') {$sign. = $key. $val;
}} $sign = Strtoupper (MD5 ($sign));
return $sign;
//The Group parameter function Createstrparam ($PARAMARR) {$strParam = '; foreach ($paramArr as $key => $val) {if ($key!= ' && $val!= ') {$strParam. = $key. ' = '. UrlEncode ($val). '
& ';
} return $strParam;
}//Parse XML functions function Getxmldata ($strXml) {$pos = Strpos ($strXml, ' xml ');
if ($pos) {$xmlCode =simplexml_load_string ($strXml, ' simplexmlelement ', libxml_nocdata);
$arrayCode =get_object_vars_final ($xmlCode);
return $arrayCode;
else {return '; }} function Get_object_vars_final ($obj) {
if (Is_object ($obj)) {$obj =get_object_vars ($obj);
} if (Is_array ($obj)) {foreach ($obj as $key => $value) {$obj [$key]=get_object_vars_final ($value);
} return $obj; {//parameter array $paramArr = Array (' App_key ' => $appKey, ' method ' => ' taobao.shop.get ', ' Format ' => ' xml ', ' V ' =&G T ' 1.0 ', ' timestamp ' => date (' y-m-d h:i:s '), ' Fields ' => ' sid,nick,title ',/* The corresponding parameters of the data to be returned, Sid corresponds to the seller's store Id,nick the seller's nickname, There's no need to return here, because you already know.
Title corresponding to the seller's shop titles, that is, the shop name * * Nick ' => $salenick//sellers nickname);
Generate Signature $sign = Createsign ($PARAMARR);
Tissue parameter $strParam = Createstrparam ($PARAMARR);
$strParam. = ' sign= '. $sign;
Access Service $url = ' http://gw.api.taobao.com/router/rest '. $strParam;
$result = file_get_contents ($url);
$result = Getxmldata ($result); $sid = $result [' Shop '] [' Sid ']; Return the seller Store id $nick = $result [' Shop '] [' Nick ']; Return the seller's nickname $title = $result [' Shop '] [' title ']; return Seller Shop title?> <php echo ' seller Store ID: '. $sid. ' <br> ';> <!--print Shop ID on page--> <php echo ' seller nickname: '. $nick. ' <br> ';> <!--print sellers nickname--> <php echo ' shop title: '. $title. '
<br> ';> <!--print Seller shop title on page-->
I hope this article will help you with your PHP programming.