简体   繁体   中英

How to send get request in ITMS url in PHP?

I have the following code which is not working. Means ITMS service dont call the URL with get request.

header('Location: itms-services://?action=download-manifest&url=http://www.mysite.com/plistReader.php?id=123');

If i remove id=123 its start working. But i need to send this as to keep id dynamic. In Session also i am unable to pass. Please help.

You need to URL-encode that question mark as %3F , as it is a reserved character. As @wroniasty pointed out, you also need to encode the = as %3D .

header('Location: itms-services://?action=download-manifest&url=http://www.mysite.com/plistReader.php%3Fid%3D123');

See also: http://www.blooberry.com/indexdot/html/topics/urlencoding.htm

Never escape URL characters by hand. Let PHP 5's functions - urlencode() and http_build_query() - do the hard work for you. This avoids issues where some of your GET parameter name/value pairs may have sensitive characters that need to be transmitted eg

<?php
    $base_url = "http://www.example.com/plistReader.php";
    $data = Array("id" => 123, "dangerous" => ":?&= are some sensitive chars");

    $itms_url = "itms-services://?action=download-manifest&url=" . urlencode($base_url . "?" . http_build_query($data));
    header('Location: ' . $itms_url);
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM