access_token; } // Parse HTTP Headers // This function takes the raw HTTP response headers and parses them to return // just the ones that are relevant or wanted. // // Function Parameters: // $raw = the raw string headers // $desired = array of header names that you want returned. // $returnType = 'string' | 'array' function parseHTTPHeaders($raw,$desired,$returnType = 'string'){ $listed = explode("\n",$raw); $parsed = array(); $return = array(); foreach($listed as $line){ if(substr($line,0,4)=='HTTP') continue; list($key,$value) = explode(': ',$line); $parsed[$key] = $value; } foreach($desired as $header){ $return[$header] = (array_key_exists($header,$parsed))?$parsed[$header]:null; } if($returnType=='array'){ return $return; } else { $output = ''; foreach($return as $header=>$value){ $output.=$header.': '.$value."\n"; } return trim($output); } }