PHP

Here is a simple example of calling the Skriv API using the PHP language.
This example prints the name of a project.

  1. <?php
  2.  
  3. // parameters - set the right values
  4. $orgId = XXX;
  5. $projectId = YYY;
  6. $pubKey = 'public-key';
  7. $privKey = 'private-key';
  8.  
  9. $url = "https://api.skriv.com/1/project/get/$orgId/$projectId";
  10.  
  11. $ch = curl_init($url);
  12. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  13. curl_setopt($ch, CURLOPT_USERPWD, "$pubKey:$privKey");
  14. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  15. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  16. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  17. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
  18.  
  19. // execute the request
  20. $res = curl_exec($ch);
  21. $data = json_decode($res, true);
  22.  
  23. // print the project name
  24. print($data['name']);
  25.