Advertisement
thimo

spreadshirt get all designs of eu marketplace

Mar 20th, 2018
653
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. <?php
  2.  
  3. $user_agent = 'test/1.0 (http://tshirtfamily.fr/; test@mail.de)';
  4. ini_set('user_agent', $user_agent);
  5.  
  6. $site_url = 'https://api.spreadshirt.net/api/v1/shops/205909/designs?locale=fr_FR&fullData=true';
  7.  
  8. $header = array();
  9. $header[] = createSprdAuthHeader("GET", $site_url);
  10. $header[] = "Content-Type: application/xml";
  11.  
  12.  
  13. $ch = curl_init();
  14. curl_setopt($ch, CURLOPT_URL, $site_url);
  15. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  16. curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
  17. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  18. curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
  19. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  20. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  21.  
  22. $resultat = curl_exec($ch);
  23.  
  24. print_r($resultat);
  25.  
  26.  
  27. function createSprdAuthHeader($method, $url) {
  28.     $apiKey = "my-api-key";
  29.     $secret = "my-api-secret";
  30.     $time = time()*1000;
  31.  
  32.     $data = "$method $url $time";
  33.     $sig = sha1("$data $secret");
  34.  
  35.     return "Authorization: SprdAuth apiKey=\"$apiKey\", data=\"$data\", sig=\"$sig\"";
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement