Today I’m trying to learn PHP, from Classic ASP. I’m trying to write a simple function that uses Zend S3 Framework to generate a signed private s3 url but my coding client keeps telling me there’s a syntax error on line 4 function get_s3_signed_url.......
<?php
require_once 'zendS3.php';
public function get_s3_signed_url($bucket, $resource, $AWS_S3_KEY, $AWS_s3_secret_key, $expire_seconds) {
$expires = time()+$expire_seconds;
// S3 Signed URL creation
$string_to_sign = "GET\n\n\n{$expires}\n/".str_replace(".s3.amazonAWS.com","", $bucket)."/$resource";
$signature = urlencode(base64_encode((hash_hmac("sha1", utf8_encode($string_to_sign), $AWS_s3_secret_key, TRUE))));
$authentication_params = "AWSAccessKeyId=".$AWS_S3_KEY;
$authentication_params.= "&Expires={$expires}";
$authentication_params.= "&Signature={$signature}";
return $link = "http://s3.amazonAWS.com/{$bucket}/{$resource}?{$authentication_params}";
}
?>
This particular function is actually posted on loads of and tutorials and I’ve basically copied and pasted it, so I can’t see what would be so wrong with it, as others are using it fine. Can somebody please tell me what this syntax error is so I can move on and go to sleep.
its wrong, please use
function get_s3_signed_url,publicfor classes