Question

Im able to create passes and sign them, I'm trying to implement a web service to register the passes and devices . i have implemented the web service end points to take care of POST, DELETE and GET

I'm having issues with the pass unable to register:

if (strtoupper($_SERVER['REQUEST_METHOD']) === "POST"
    && isset($_SERVER['HTTP_AUTHORIZATION'])
    && strpos($_SERVER['HTTP_AUTHORIZATION'], 'ApplePass') === 0
    && $request[2] === "devices"
    && $request[4] === "registrations") {

    $auth_key = str_replace('ApplePass ', '', $_SERVER['HTTP_AUTHORIZATION']);

$_SERVER['HTTP_AUTHORIZATION'] is returning null so i wont enter the register a pass function

i have installed the ssl certificate from godaddy in my cPanel manager anything else to be done with the server?

im testing my web service using Echo (mac store)

also i ve been creating passes and nothing is showing in my logs

any help will be appreciated

new to php and passbook

thanks

Était-ce utile?

La solution

Your issue is that you are not correctly getting hold of the Authorisation header.

If you are using Apache, then most PHP/Apache distributions come with a built in function apache__request_headers().

You can use this as follows:

$headers = apache_request_headers();

if (strtoupper($_SERVER['REQUEST_METHOD']) === "POST"
    && isset($headers['Authorization'])
    && strpos($headers['Authorization'], 'ApplePass') === 0
    && $request[2] === "devices"
    && $request[4] === "registrations") {

    $auth_key = str_replace('ApplePass ', '', $headers['Authorization']);

If your distribution does not have the apache_request_headers function you can replicate it.

if (!function_exists('apache_request_headers')) {
    function apache_request_headers() {
        foreach($_SERVER as $key=>$value) {
            if (substr($key,0,5)=="HTTP_") {
                $key=str_replace(" ","-",ucwords(strtolower(str_replace("_"," ",substr($key,5)))));
                $out[$key]=$value;
            }else{
                $out[$key]=$value;
            }
        }
        return $out;
    }
}

For Nginx then add the following fastcgi_param to your config, then you can access the variable with $_SERVER['Authorization'].

fastcgi_param  Authorization      $http_authorization;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top