UF t+ v2d Docking, PHP version

Source: Internet
Author: User
Tags begin rsa private key


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

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.