Taobao Open API Newbie Tutorial--Get seller store ID based on seller nickname

Source: Internet
Author: User
Original address: Http://blog.qita.in
  1. Header ("Content-type:text/html;charset=utf-8");
  2. /* This program features: root seller nickname get seller shop sid, and store title * *
  3. Config
  4. $appKey = ' 12345678; Your secret key.
  5. $appSecret = ' 123456789 ';
  6. $usernick = ' Grayvoice '; Your user name
  7. $salenick = ' water-deficient fish '; Seller Nickname
  8. Signature functions
  9. function Createsign ($PARAMARR) {
  10. Global $appSecret;
  11. $sign = $appSecret;
  12. Ksort ($PARAMARR);
  13. foreach ($paramArr as $key = = $val) {
  14. if ($key! = "&& $val! =") {
  15. $sign. = $key. $val;
  16. }
  17. }
  18. $sign = Strtoupper (MD5 ($sign));
  19. return $sign;
  20. }
  21. Group parameter functions
  22. function Createstrparam ($PARAMARR) {
  23. $strParam = ";
  24. foreach ($paramArr as $key = = $val) {
  25. if ($key! = "&& $val! =") {
  26. $strParam. = $key. ' = '. UrlEncode ($val). ' & ';
  27. }
  28. }
  29. return $strParam;
  30. }
  31. Parsing XML functions
  32. function Getxmldata ($strXml) {
  33. $pos = Strpos ($strXml, ' xml ');
  34. if ($pos) {
  35. $xmlCode =simplexml_load_string ($strXml, ' simplexmlelement ', libxml_nocdata);
  36. $arrayCode =get_object_vars_final ($xmlCode);
  37. return $arrayCode;
  38. } else {
  39. Return ';
  40. }
  41. }
  42. function Get_object_vars_final ($obj) {
  43. if (Is_object ($obj)) {
  44. $obj =get_object_vars ($obj);
  45. }
  46. if (Is_array ($obj)) {
  47. foreach ($obj as $key = = $value) {
  48. $obj [$key]=get_object_vars_final ($value);
  49. }
  50. }
  51. return $obj;
  52. }
  53. Parameter array
  54. $PARAMARR = Array (
  55. ' App_key ' = $appKey,
  56. ' Method ' = ' taobao.shop.get ',
  57. ' Format ' = ' xml ',
  58. ' V ' = ' 1.0 ',
  59. ' Timestamp ' + date (' y-m-d h:i:s '),
  60. ' Fields ' = ' sid,nick,title ',/* The corresponding parameters of the data to be returned, SID corresponds to seller store Id,nick corresponding seller nickname, here actually do not return, because already know. Title corresponds to the seller's store name, which is the store * *
  61. ' Nick ' = $salenick//seller Nickname
  62. );
  63. Generate signature
  64. $sign = Createsign ($PARAMARR);
  65. Organizational parameters
  66. $strParam = Createstrparam ($PARAMARR);
  67. $strParam. = ' sign= '. $sign;
  68. Access to services
  69. $url = ' http://gw.api.taobao.com/router/rest '. $strParam;
  70. $result = file_get_contents ($url);
  71. $result = Getxmldata ($result);
  72. $sid = $result [' Shop '] [' Sid ']; return Seller Store ID
  73. $nick = $result [' Shop '] [' Nick ']; Back to seller nickname
  74. $title = $result [' Shop '] [' title ']; Back to Seller store title
  75. >

  76. ';>

  77. ';>

  78. ';>
Copy Code
  • 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.