Skip to content

Instantly share code, notes, and snippets.

@inkeliz
Last active August 21, 2017 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inkeliz/b5e89243799fd2e20fbf9d9ecd3b0354 to your computer and use it in GitHub Desktop.
Save inkeliz/b5e89243799fd2e20fbf9d9ecd3b0354 to your computer and use it in GitHub Desktop.
<?php
/**
* Created by PhpStorm.
* User: lucas
* Date: 21/08/2017
* Time: 20:21
*/
// Endpoint:
$url = 'https://api.nasa.gov/planetary/sounds';
$param = [
'q' => 'apollo',
'limit' => 5,
'api_key' => 'DEMO_KEY' // Troque por sua chave (https://api.nasa.gov/index.html#apply-for-an-api-key)
];
// cURL:
$ch = curl_init($url . '?' . http_build_query($param, '', '&', PHP_QUERY_RFC3986));
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_REDIR_PROTOCOLS => CURLPROTO_HTTPS,
CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_2,
CURLOPT_FOLLOWLOCATION => 0,
CURLOPT_SSL_VERIFYPEER => 1,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_CAINFO => __DIR__ . DIRECTORY_SEPARATOR . 'cacert-2017-06-07.pem', // Download: https://curl.haxx.se/ca/cacert-2017-06-07.pem
CURLOPT_PINNEDPUBLICKEY => 'sha256//GVp1NQrwv6iySxXhJCz2sAwNN3TWaoTDt6Wz9ATGgXs=', // Validade: 04/2018
]
);
echo curl_exec($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment