Php keeps giving me an incorrect response for android in-app-billing server verification
<p>For some reason I got this script to work without fault but once i tried to decode the JSON the script started messing up. I reverted back to the old script and it still isn't working. Here it is below. $result keeps giving me 0 which if the PHP documentation is correct means that the verification failed. I have double checked public_key.pem to see if it is correct and it is. I have also checked to see if signedData and signature are being sent and they are being sent. What could possibly be wrong with this script?</p>

<pre><code>&lt;?php
$signed_data = $_POST['signedData'];
$signature = $_POST['signature'];
$fp = fopen("./public_key.pem", "r");
$cert = fread($fp, 451);
fclose($fp);
$pubkeyid = openssl_get_publickey($cert);
$signed_data = trim($signed_data);
$signature = base64_decode($signature);

$result = openssl_verify($signed_data, $signature, $pubkeyid, OPENSSL_ALGO_SHA1);
if ($result == 1) {
    echo 'correct';
} else if ($result == 0) {
    echo 'fail';
    echo '||';
    echo $pubkeyid;
    echo '||';
    echo $signed_data;
} else {
    echo 'epic fail';
}
openssl_free_key($pubkeyid);
?&gt;
</code></pre>
