Remote Authentication for support

Remote Authentication for support

I have written a sign up script for Remote Authentication in PHP. I have used php md5 function for apikey.
It gives error :
{"result":"failure","cause":"Unauthorized Access"}

Can you please help me what i am doing wrong?
Here is my code for apikey :

$array = array($operation, $email, $loginName, $fullName, $utype, $authkey, $ts);
$apikey = md5(serialize($array));