php - file_get_contents implements POST data, https
给我你的怀抱
给我你的怀抱 2017-05-27 17:42:27
0
3
685

As the title states, regardless of the curl method, POST is given to the interface data, but the interface cannot obtain it or there is a problem with returning parameters.

Post the code:

    $POSTFIELDS = array("receipt-data" => $receipt_data);    //
    $POSTFIELDS = json_encode($POSTFIELDS);    // 注释了也没用
    $url = "https://sandbox.itunes.apple.com/verifyReceipt";

    $context = stream_context_create(array(
        'http' => array(
            'method'  => 'POST',
            'header'  => "Content-type: application/x-www-form-urlencoded",
            'content' => http_build_query($POSTFIELDS),
            'timeout' => 20,
        )
    ));
    return file_get_contents($url, false, $context);

$receipt_data data format is correct because curl testing can return correct information.

But for file, the returned parameters are always wrong no matter what. I don’t know what the problem is.

给我你的怀抱
给我你的怀抱

reply all(3)
伊谢尔伦

What you said upstairs is correct. Regarding this problem, it is actually an error when interacting with the Apple payment interface and transmitting data.

http_build_query is not required

某草草

Let’s first see what the server gets. . . Are you passing json? Then there is the POST in form format. . . Without key=>value, the backend can only get strings in json format

左手右手慢动作

HTTPS needs to enable SSL
Get this to help you
http://www.jb51.net/article/4...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template