Home > Back-end >  Who understand PHP a great god, could you give me a hand and changed this code into the Delphi? than
Who understand PHP a great god, could you give me a hand and changed this code into the Delphi? than

Time:12-27

<? PHP

$access_key="kefLdiMu";
$access_secret="383354 d5856ba4aec8c72b9eddbaa5905f9";
$url="http://openapi.quanda.com/api/erp/v1/product/stock";

$params=[
"Params=& gt;"
"Shop_id"=& gt; 113,
"Data"=& gt;

"Code"=& gt; "Mtcode_3310,"
"Stock"=& gt; 20
],

"Code"=& gt; "1233",
"Stock"=& gt; 20
]
]
],
"Access_key=& gt;" $access_key,
"Timestamp"=& gt; The time ()
];

$params [" signature "]=getSign ($params, $access_secret);

Var_dump (doPost ($url, $params));


The function getSign ($params, $access_secret) {
$STR='access_key=' $params [' access_key ']. '& amp; Params='. Json_encode ($params [' params'], JSON_UNESCAPED_UNICODE). '& amp; Timestamp='$params [' timestamp] $access_secret;
Return the md5 ($STR);
}


Function the doPost ($url, $param)
{
$ch=curl_init ();
Curl_setopt ($ch, CURLOPT_URL, $url);
Curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
Curl_setopt ($ch, CURLOPT_HEADER, false);
Curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
Curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);//no SSL certification
Curl_setopt ($ch, CURLOPT_POST, true);
Curl_setopt ($ch, CURLOPT_POSTFIELDS json_encode ($param));
Curl_setopt ($ch, CURLOPT_HTTPHEADER, array (' the content-type: Application/json));
$result=the curl_exec ($ch);
Curl_close ($ch);
return $result;
}

  • Related