Glen Joyner
Glen Joyner

Reputation: 23

Paypal webhooks reach server, but values are blank

I'm trying to use the webhook simulator to be sure that the information is at least making it to our server before moving forward. The good news is that in my log I see that the request did something, but the problem is all variables are blank. I'm using php, and $_GET, $_POST, and $_REQUEST are all empty arrays according to my printouts. Anyone have any tips on how to troubleshoot this particular issue?

The following is the only code on our server (again, just want to see if the data made it).

<?php
    function write_to_log($text) {
        try {
            $file = fopen("../../../paypal_test_log.txt", "a");
            $text = date("m/d/Y H:i:s") . " -- " . $text . "\n";
            fwrite($file, $text);
            fclose($file);
        } catch(Exception $e) {
            echo 'error<br/>';
            echo $e->getMessage();
        }
    }
    header('HTTP/1.1 200 OK'); 
    write_to_log('===============================================testing post');
    write_to_log(print_r($_POST, true));
    write_to_log('===============================================get');
    write_to_log(print_r($_GET, true));
    write_to_log('===============================================request');
    write_to_log(print_r($_REQUEST, true));
?>

Server log after event:

07/14/2016 15:07:22 --
===============================================testing post 07/14/2016 15:07:22 -- Array ( )

07/14/2016 15:07:22 --
===============================================get 07/14/2016 15:07:22 -- Array ( )

07/14/2016 15:07:22 --
===============================================request 07/14/2016 15:07:22 -- Array ( )

Upvotes: 2

Views: 589

Answers (1)

vitaliy
vitaliy

Reputation: 166

To get the request body you have to use 'php://input', example file_get_contents('php://input');

To verify request authority you have to check $_SERVER global array

Upvotes: 7

Related Questions