質問

I have a working 3rd party php codes verify the receipt sent from ipad. but it seems https://sandbox.itunes.apple.com/verifyReceipt no long response to my php code. there's not even an error stat like {"status":21000} if I visite the url directly. I've tried different ways on server side, like curl_exec($ch); or file_get_contents even the simple test get nothing returned at all.

$result = file_get_contents('https://sandbox.itunes.apple.com/verifyReceipt');
echo $result;

I wonder if this is caused by heartbleed and what can I do?

my original working php code:

if ($isSandbox) {   
        $endpoint = 'https://sandbox.itunes.apple.com/verifyReceipt';   
    }   
    else {   
        $endpoint = 'https://buy.itunes.apple.com/verifyReceipt';   
    }   

// Connect to Apple server and validate.
$postData = json_encode(array("receipt-data" => $receipt));

$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded",
        'method'  => 'POST',
        'content' => $postData
    ),
);
$context  = stream_context_create($options);
$result = file_get_contents($endpoint, false, $context);
役に立ちましたか?

解決

Well, after hours searching and checking, I finally figure this out, here's what happened:

  1. I upload the test file to another server, turns out it's working so not a php source problem.
  2. I added

    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    

    to the php file got the error code is file-get-contents Couldn't resolve host name

  3. so I remember I yum update all the server software yesterday to deal with heartbleed. and seems some update modified the resolv.conf.
  4. I changed the resolv.conf added google nameserver 8.8.8.8 but still not working
  5. restart the nginx and php-fpm, problem solved
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top