Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $user_agent = 'test/1.0 (http://tshirtfamily.fr/; test@mail.de)';
- ini_set('user_agent', $user_agent);
- // Default values
- $designId = 0;
- $url = '';
- if (!empty($_REQUEST['url'])) {
- $url = strip_tags(htmlentities($_REQUEST['url']));
- preg_match('/designs\/(\w*)/i', $url, $matches);
- $designId = $matches[1];
- }
- $site_url = 'https://api.spreadshirt.net/api/v1/shops/205909/designs/'.$designId.'?locale=fr_FR&fullData=true';
- $header = array();
- $header[] = createSprdAuthHeader("GET", $site_url);
- $header[] = "Content-Type: application/xml";
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $site_url);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- $resultat = curl_exec($ch);
- print_r($resultat);
- function createSprdAuthHeader($method, $url)
- {
- $apiKey = "my-api-key";
- $secret = "my-api-secret";
- $time = time()*1000;
- $data = "$method $url $time";
- $sig = sha1("$data $secret");
- return "Authorization: SprdAuth apiKey=\"$apiKey\", data=\"$data\", sig=\"$sig\"";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement