Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $headers = array (
- 'X-EBAY-API-COMPATIBILITY-LEVEL: 507',
- 'X-EBAY-API-DEV-NAME: ABCD',
- 'X-EBAY-API-APP-NAME: EFGH',
- 'X-EBAY-API-CERT-NAME: IJKL',
- 'X-EBAY-API-SITEID: 0',
- );
- $accessToken = "AAACEdEose0cBAAAB8qnMVCmfNRQSNT2CCCTZBB90eMl7UpaFZBuYTAqWvYkhP9gJsoFd7ZAfAWxe6yTfh7jZBpaixhPHR6TO3n1xLiItM0FlccuVEy9x";
- $url = "https://graph.facebook.com/me?access_token=" . $accessToken;
- $repeat = 3;
- /**
- * verbose
- **/
- $start = microtime(true);
- for ($i = 0; $i < $repeat; $i++) {
- $session = curl_init();
- curl_setopt($session, CURLOPT_URL, $url); // Oops - wrong URL for API
- curl_setopt($session, CURLOPT_HTTPHEADER, $headers); // Set headers to above array
- curl_setopt($session, CURLOPT_HEADER, true); // Display headers
- curl_setopt($session, CURLOPT_VERBOSE, true); // Display communication with server
- curl_setopt($session, CURLOPT_RETURNTRANSFER, true); // Return data instead of display to std out
- curl_exec($session);
- curl_close($session);
- }
- echo "Verbose time: " . (microtime(true) - $start) . " seconds.\n";
- /**
- * fgc
- **/
- $start = microtime(true);
- for ($i = 0; $i < $repeat; $i++) {
- file_get_contents($url);
- } echo "File get contents time: " . (microtime(true) - $start) . " seconds.\n";
- /**
- * andrewF
- **/
- $start = microtime(true);
- for ($i = 0; $i < $repeat; $i++) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- //curl_setopt($ch, CURLOPT_HEADER, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0); // Return contents only
- //curl_setopt($ch, CURLOPT_VERBOSE, 1); // Display communication with server
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return results instead of outputting
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); // Give up after connecting for 10 seconds
- curl_setopt($ch, CURLOPT_TIMEOUT, 60); // Only execute 60s at most
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // Don't verify SSL cert
- $response = curl_exec($ch);
- curl_close($ch);
- }
- echo "AndrewF time: " . (microtime(true) - $start) . " seconds.\n";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement