示例#1
0
    }
    $client->authenticate($_GET['code']);
    $_SESSION['token'] = $client->getAccessToken();
    header('Location: ' . $redirect);
}
if (isset($_SESSION['token'])) {
    $client->setAccessToken($_SESSION['token']);
}
// Check to ensure that the access token was successfully acquired.
if ($client->getAccessToken()) {
    try {
        if (empty(listReportingJobs($youtubeReporting, $htmlBody))) {
            $htmlBody .= sprintf('<p>No jobs found.</p>');
        } else {
            if ($_GET['reportUrl']) {
                downloadReport($youtubeReporting, $_GET['reportUrl'], $htmlBody);
            } else {
                if ($_GET['jobId']) {
                    retrieveReports($youtubeReporting, $_GET['jobId'], $htmlBody);
                }
            }
        }
    } catch (Google_Service_Exception $e) {
        $htmlBody .= sprintf('<p>A service error occurred: <code>%s</code></p>', htmlspecialchars($e->getMessage()));
    } catch (Google_Exception $e) {
        $htmlBody .= sprintf('<p>An client error occurred: <code>%s</code></p>', htmlspecialchars($e->getMessage()));
    }
    $_SESSION['token'] = $client->getAccessToken();
} else {
    // If the user hasn't authorized the app, initiate the OAuth flow
    $state = mt_rand();
示例#2
0
// The username and password of your report user. This can be configured in the CA interface under Settings->Users
$adyenReportUsername = "******";
$adyenReportPassword = "******";

// After you have received and stored a notification, you can create a server which calls the downloadReport function 
//  for all the REPORT_AVAILABLE notifications. This process must be separated from accepting notifications!

// The REPORT_AVAILABLE notification contains the url of the report in the reason field. 
$reason="https://ca-test.adyen.com/reports/download/MerchantAccount/<YourMerchantAccount>/payment_report_batch_1.csv";

// The location of the file where we have to store it.
$localeFileName = getLocaleFilename('/tmp',$reason);

// This will download the remote file and stores it under $localeFileName => /tmp/payment_report_batch_1.csv
$downloadResult = downloadReport($reason, $localeFileName) ;
echo "downloadResult: ".$downloadResult;

function downloadReport($reportLocationRemote, $reportLoactionLocale) {
	global $adyenReportUsername, $adyenReportPassword;

	$login = '******' .base64_encode($adyenReportUsername.':'.$adyenReportPassword) ;
	$options = array(
		'http'=> array(
			'method'=>'GET',
			'header'=>$login
			)
		);
	$context = stream_context_create($options);
	// Open the remote file
	$remoteResource = fopen($reportLocationRemote, 'r', false, $context);