UF t+ V2 Docking php version, using OrgID authentication method.
<?phprequire_once dirname (__file__). ’/.. /extensions/vendor/vendor/autoload.php '; use \firebase\jwt\jwt;class TestController extends CController{const AppKey = ' 192be680fsfjsdjfskljfsjlkgjklsdjfgkldsjlk '; Const Appsecret = ' DFASDFSA '; Const USERNAME = ' 133333333 '; Const Password = ' 56456 '; Const AccountNum = ' 4 ';//formal Environment function Getmillisecond () {list ($t 1, $t 2) = Explode (", microtime ()); return (float) sprintf ('%.0f ', (Floatval ($t 1) + floatval ($t 2)) * 1000); } public Function Actiontest () {$uri = ' Http://127.0.0.1:8080/tplus/api/v2/collaborationapp/GetAnonymousTPlu Stoken? Isfree=1 '; Key $privateKey = <<<eod-----BEGIN RSA private key----------END RSA private key-----EOD; $token = ["Appkey" and "Self::appkey", "OrgID" and "123456789", "Appsecret" +-Self :: Appsecret]; $tokens = Json_encode ($token); $payload = [' Sub ' = ' cjt ', ' Exp ' = $this->getmillisecond () + 30000, ' datas ' and MD5 ($tokens)]; $JWT = Jwt::encode ($payload, $privateKey, ' RS256 '); $auth = Array (' appKey ' = = Self::appkey, ' authInfo ' and ' = ' $jwt, ' orgId ' = ' 1234567 89 ',); $Authorization = Base64_encode (Stripslashes (Json_encode ($auth))); $header = Array ("Authorization: $Authorization"); $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, $uri); curl_setopt ($ch, Curlopt_httpheader, $header); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_postfields, Http_build_query ($args)); curl_setopt ($ch, Curlopt_post, 1); $response = curl_exec ($ch); echo "<pre>"; Print_r ($response); echo "</pre>"; Curl_close ($ch); $response = Json_decode ($response, true); /** * On: Get token */$payload = [ ' Sub ' = ' cjt ', ' exp ' = = $this->getmillisecond () + 30000, ' datas ' = MD5 ($tokens ), "access_token" = $response [' Access_token '],]; $JWT = Jwt::encode ($payload, $privateKey, ' RS256 '); $auth 2 = Array (' appKey ' = = Self::appkey, ' authInfo ' = = $JWT, ' orgId ' = ' 123456 789 ',); $Authorization 2 = Base64_encode (Stripslashes (Json_encode ($auth 2)); $uri 2 = ' http://127.0.0.1/tplus/api/v2/inventory/Query '; $args = Array (' Code ' = ' 16742 ');//test data $header 2 = Array ("Authorization: $Authorization 2". ’’, ); $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, $uri 2); curl_setopt ($ch, Curlopt_httpheader, $header 2); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_postfields, Http_build_query ($args)); curl_setopt ($ch, Curlopt_post, 1); $response 1 = curl_exec ($ch); echo "<pre>"; Print_r ($response 1); echo "</pre>"; Curl_close ($ch); }}?>
Questions Contact q:657122957
UF t+ v2d Docking, PHP version