解码URL编码的GET参数

时间:2016-12-11 11:03:37

标签: php api url-encoding

在拦截应用程序的流量时,我获得了这个GET API,但我不知道如何对它们进行解码,使它们看起来像它们实际上是什么。

  

/ API / V1 /转诊/ CREATEUSER phoneNumber的= 7018805137&安培; deviceImeiId = lQAHMiAwBx%2B%2FchlgHKjWfA%3D%3D%0A&安培; hardwareSerialNumber = BCZ%2Bb5VrI84UN%2FWXJj8hyQ%3D%3D%0A&安培; MACADDRESS = pDQheRx1nNFqOz%2Fw9Y9bI3I96uVKXjhkDXNhNgV% 2FyGw%3D%0A&安培; androidID = PQ9kdlHyznGdGKcl0QYh3hp4XeRUz0bBVMnABcxRsZ8%3D%0A&安培; referralCode = 7JMYUZ&安培; lastEnabledTime = 1481449847956&安培;注册= 1481449669855&安培; installationTime = 1481449669855

1 个答案:

答案 0 :(得分:0)

如果变量作为Get请求发送到您的服务器,您可以读取变量,如...

$ _获取[' phoneNumber'],$ _GET [' hardwareSerialNumber']等等

如果你只是在寻求帮助来解码字符串......

$urlstring = 'phoneNumber=7018805137&deviceImeiId=lQAHMiAwBx%2B%2FchlgHKjWfA%3D%3D%0A&hardwareSerialNumber=bcZ%2Bb5VrI84UN%2FWXJj8hyQ%3D%3D%0A&macAddress=pDQheRx1nNFqOz%2Fw9Y9bI3I96uVKXjhkDXNhNgV%2FyGw%3D%0A&androidID=PQ9kdlHyznGdGKcl0QYh3hp4XeRUz0bBVMnABcxRsZ8%3D%0A&referralCode=7JMYUZ&lastEnabledTime=1481449847956&updateTime=1481449669855&installationTime=1481449669855';

foreach (explode('&', $urlstring) as $chunk) {
    $param = explode("=", $chunk);

    if ($param) {
        printf("Value for parameter \"%s\" is \"%s\"<br/>\n", urldecode($param[0]), urldecode($param[1]));
    }
}

将打印以下内容

  

参数&#34; phoneNumber&#34;的值是&#34; 7018805137&#34;

     

参数&#34; deviceImeiId&#34;的值是&#34; lQAHMiAwBx + / chlgHKjWfA ==&#34;

     

参数&#34; hardwareSerialNumber&#34;的值是   &#34; bcZ + b5VrI84UN / WXJj8hyQ ==&#34;

     

参数&#34; macAddress&#34;的值是   &#34; pDQheRx1nNFqOz / w9Y9bI3I96uVKXjhkDXNhNgV / yGw =&#34;

     

参数&#34; androidID&#34;的值是   &#34; PQ9kdlHyznGdGKcl0QYh3hp4XeRUz0bBVMnABcxRsZ8 =&#34;

     

参数值&#34; referralCode&#34;是&#34; 7JMYUZ&#34;

     

参数值&#34; lastEnabledTime&#34;是&#34; 1481449847956&#34;

     

参数值&#34; updateTime&#34;是&#34; 1481449669855&#34;

     

参数值&#34; installationTime&#34;是&#34; 1481449669855&#34;