PHP Example

The following code calls the Get Themes API operation that retrieves all GlobalGiving themes.

In this example, the Accept header is used to request that the response be returned in JSON format.

Sample Request

                  <?php
                  // Create a stream
                  $opts = array(
                    'http'=>array(
                      'method'=>"GET",
                      'header'=>"Accept: application/json\r\n"
                    )
                  );
                  $context = stream_context_create($opts);
                  $base = 'https://api.globalgiving.org/api';
                  $operation = '/public/projectservice/themes';
                  $api_key = 'YOUR_API_KEY';
                  $query_string = "api_key=" . "$api_key";
                  $url = "$base$operation?$query_string";
                  // Open the url using the HTTP headers set above
                  $output = file_get_contents($url, false, $context);
                  echo $output;
                  ?>            
               

Sample JSON Response

                           
                  {"themes":{"theme":[{"id":"animals","name":"Animals"},{"id":"children","name":"Children"},{"id":"climate","name":"Climate Change (GG Green)"},{"id":"democ","name":"Democracy and Governance"},{"id":"disaster","name":"Disaster Recovery"},{"id":"ecdev","name":"Economic Development"},{"id":"edu","name":"Education"},{"id":"env","name":"Environment"},{"id":"finance","name":"Microfinance"},{"id":"gender","name":"Women and Girls"},{"id":"health","name":"Health"},{"id":"human","name":"Humanitarian Assistance"},{"id":"rights","name":"Human Rights"},{"id":"sport","name":"Sport"},{"id":"tech","name":"Technology"}]}}