Anonymous
Not logged in
Talk
Contributions
Create account
Log in
wiki
Search
Editing
API/Example: PHP
From wiki
Namespaces
Page
Discussion
More
More
Page actions
Read
Edit
History
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
= Example: PHP = This example demonstrates how to use the **Verofy API** from PHP with the Yii HTTP Client. __TOC__ == Overview == The example covers: * Authenticating via refresh and access tokens * Retrieving a list of map sites filtered by `externalId` * Updating a map site record by ID Ensure that the **Yii HTTP Client** component is installed and properly configured. ---- == Example Script == <syntaxhighlight lang="php"> <?php use yii\httpclient\Client; $client = new Client([ 'baseUrl' => "https://apidev.verofy.veronetworks.com/v1", ]); $refreshToken = getRefreshToken($client); $accessToken = getAccessToken($client, $refreshToken); // ------------------------------------------------------------ // Example #1: Get a list of map sites filtered by externalId // ------------------------------------------------------------ $externalId = 1002; $mapPointId = null; $rs = $client->createRequest() ->setMethod('GET') ->setUrl('/map-site?filter[externalId]=' . $externalId) ->setHeaders(['Authorization' => 'Bearer ' . $accessToken]) ->send(); foreach ($rs->data['items'] as $item) { if (isset($item['externalId']) && $item['externalId'] == $externalId) { // We found the specific map site by its externalId $mapPointId = $item['id']; } } // ------------------------------------------------------------ // Example #2: Update map point by its ID // ------------------------------------------------------------ $request = $client->createRequest() ->setMethod('PATCH') ->setUrl("map-site/update?id={$mapPointId}") ->setFormat(Client::FORMAT_JSON) ->setHeaders([ 'Authorization' => 'Bearer ' . $accessToken, 'Accept' => 'application/json', ]) ->setData([ 'latitude' => 34.00, 'longitude' => 33.00, 'name' => 'John Doe', 'address1' => '3551 Poppi Ave, Evans, CO 80620', // Additional attributes... ]); // Send the request $response = $request->send(); </syntaxhighlight> ---- == Notes == * Replace <code>getRefreshToken()</code> and <code>getAccessToken()</code> with your own authentication logic. * Always store tokens securely and avoid committing them to source control. * The examples assume your API instance is reachable at <code>https://apidev.verofy.veronetworks.com/v1</code> β adjust to your environment if needed. ---- ''Next:'' β [[API/Endpoint Documentation]]
Summary:
Please note that all contributions to wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation
Verofy API
Home
Getting Started
Authentication
Endpoints
Models
Example: PHP
Verofy UI
Protected Segment Functionality
Navigation
Special pages
Wiki tools
Wiki tools
Page tools
Page tools
User page tools
More
What links here
Related changes
Page information
Page logs