Remote Authentication for support

Remote Authentication for support

I have written script for remote Authentication for support in PHP. But it gives
{"result":"failure","cause":"Unauthorized Access"} error.
I think problem in generate Apikey so. I have used MD5 function of php to generate the apikey.
Here is my code :
$array = array($operation, $email, $loginName, $fullName, $utype, $authkey, $ts);

$apikey = md5(serialize($array));

Please guide me what i am doing wrong.

Thanks