# PHP - Data Explorer API Example

**URL:** <https://meta.discourse.org/t/php-data-explorer-api-example/348668>\
**Category:** Data & reporting\
**Tags:** rest-api\
**Created:** [January 23, 2025, 7:04pm UTC](https://meta.discourse.org/t/php-data-explorer-api-example/348668 "2025-01-23T19:04:19Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)\
**Post date:** [January 23, 2025, 7:48pm UTC](https://meta.discourse.org/t/php-data-explorer-api-example/348668/2 "2025-01-23T19:48:51Z")

</div>

I’d trim most of the comments to make it easier to read 🙂  
Some comments are unnecessary, like:

```plaintext
// Obtain result
//
$result = curl_exec( $ch );

```

or

```plaintext
// close curl session
curl_close( $ch );

```

Also, know you can set the syntax highlighting by appending the language name to the first line of backticks:

````plaintext
```php
$headers = array("Content-Type: multipart/form-data;","Api-Key: $api_key","Api-Username: system",);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
```

````

Renders as

```php
$headers = array("Content-Type: multipart/form-data;","Api-Key: $api_key","Api-Username: system",);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);

```

---

_[View the full topic](https://meta.discourse.org/t/php-data-explorer-api-example/348668)._
