Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

docs(backend): Add PHP backend example #401

Merged
merged 4 commits into from
May 25, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/source/documentation.html.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,23 @@ This position is an array of two numbers, representing the lattitude and the lon
</tbody>
</table>

### Backend

You can also query the Places API from your backend, here is an example with our [PHP API Client](https://github.com/algolia/algoliasearch-client-php). It requires a registered [Places account](https://www.algolia.com/users/sign_up/places).

```php
<?php
$appId = 'YOUR_PLACES_APP_ID';
$apiKey = 'YOUR_PLACES_API_KEY';

$client = new \AlgoliaSearch\Client($appId, $apiKey);
$places = $client->initPlaces($appId, $apiKey);

$data = json_encode(array('query' => 'Paris'));
$result = $places->search($data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this has to be called like:

$places->search($query);

No need for the json_encode.
See: https://github.com/algolia/algoliasearch-client-php/blob/master/src/AlgoliaSearch/Index.php#L507

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, just pushed a simplification.

var_dump($result);
```

### REST API

Behind the places.js the JavaScript library lies a complete REST API. Read the underlying [REST API documentation](rest.html).
Expand Down