Transactions by date Pagseguro PHP

0

Hello, I need to check the transactions made on a pagseguro account, I'm using:

$initialDate = '2016-05-10';
$finalDate = '2016-06-10';
$email_pagseguro = '[email protected]';
$token_pagseguro = '**************************';


$url = 
'
    https://ws.pagseguro.uol.com.br/v2/transactions
    ?initialDate='.$initialDate.'T00:00
    &finalDate='.$finalDate.'T00:00
    &page=1
    &maxPageResults=100
    &email='.$email_pagseguro.'
    &token='.$token_pagseguro
;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch) or curl_error($ch);
curl_close ($ch);
return $output;

$transaction = simplexml_load_string($output);

echo $transaction -> transactions -> transaction -> status."<BR />";
echo $transaction -> transactions -> transaction -> paymentMethod."<BR />";
echo $transaction -> transactions -> transaction -> type."<BR />";

#

Does not return anything, where is the error?

    
asked by anonymous 10.06.2016 / 21:23

1 answer

3

Assuming that cURL is installed and with the SSL protocols required by pagseguro , the only error I find in your code is:

return $output;

If you do return , the following code does not run!
Delete this line and you should already have access to the content of the $output variable in the code you use to parse .

Debug

To see what is collected by cURL, you can do as suggested in the comments:

// ...
$output = curl_exec ($ch) or curl_error($ch);
var_dump($output);

You can also see if cURL is installed:

if (!function_exists('curl_init')) {
  die("Falta o cURL!");
}
    
11.06.2016 / 02:34