Function not returning the URL

I have a function below that is meant to return a URL.

<?php
require_once('./HMAC.php'); 
// 
// 
// 
function getS3Redirect($bucketName, $objectName) 
{ 
$accessKey = "private"; 
$secretKey = "private"; 
$S3_URL = "http://" . $bucketName . ".s3.amazonaws.com"; 
$expires = time() + (60*5); 
$stringToSign = "GETnnn" . $expires . "n/" . $bucketName . $objectName; 
$hasher =& new Crypt_HMAC($secretKey, "sha1"); 
$sig = $hasher->hash(trim($stringToSign)); 
$sig = hex2b64($sig); 
$sig = rawurlencode(trim($sig)); 

$signedurl = "$S3_URL$objectName?AWSAccessKeyId=$accessKey&Expires=$expires&Signature=$sig";
$hrefString ="<a href= "$signedurl">$signedurl </a>";

//echo $hrefString;
return $hrefString;

//return "$S3_URL$objectName?AWSAccessKeyId=$accessKey&Expires=$expires&Signature=$sig"; 

} 
// 
// 
function hex2b64($str) 
{ 
$raw = ''; 
for ($i=0; $i < strlen($str); $i+=2) 
{ 
$raw .= chr(hexdec(substr($str, $i, 2))); 
} 
return base64_encode($raw); 
} 
 ?>

<html>
<head>
<title>Untitled Document</title>
</head>

<body>


<p>LINK</p>
  
  <p><?php
    getS3Redirect("test", "test.zip")
  ?></p>
  
</body>
</html>

When I call the function with :

<?php getS3Redirect("test", "test.zip") ?>

Nothing is returned.

Also whenever I run the php I get a bunch of HTTP header information on the page.

Any ideas?

Thanks in advance.

Leejayd

Also whenever I run the php I get a bunch of HTTP header information on the page.

That’s probably your problem. What kind of ‘information’ are you getting?

Sponsor our Newsletter | Privacy Policy | Terms of Service