PHP SDK

To simplify the work with the ReportingAPI REST API, the SDK contains a simple URL generator. You can use it to generate, sign URLs with provided parameters. You have to create an instance from the ReportingApiUrlGenerator class.

  • Instantiating the ReportingApiUrlGenerator class.

    $urlGenerator = new ReportingApiUrlGenerator("3c2819e2026d6168",
          "40b09db878d34106a0af231d4286f3c1e65169be40eb26f300703c712ef574a0");
    
  • The default expiration for the signed URLs is 1 hour. You can use the DefaultSignatureExpiration property on the ReportingApiUrlGenerator to change it.

    $$urlGenerator->defaultExpirationDelta = 7200; //2 hours
    
  • Get a signed URL for an action (default http method is GET)

    $parameters = array("studyId" => 537);
    $url = $urlGenerator->GetSignedUrl("GetMediaList", $parameters);
    
  • Get a signed URL for POST http method action

    $parameters = array("studyId" => 537);
    $url = $urlGenerator->GetSignedUrl("GetMediaList", $parameters, "POST");
    
  • Get a signed URL for an action for longer Expiration (2 hours for example)

    $parameters = array("studyId" => 537);
    $url = $urlGenerator->GetSignedUrl("GetMediaList", $parameters, "GET", 7200);
    
  • To interact with the REST Api, get a signed Url, and call it. For example to get a study’s medias.

    $parameters = array("studyId" => 537);
    $url = $urlGenerator->GetSignedUrl("GetMediaList", $parameters);
    $response = file_get_contents($url);