PHP code example of grafstorm / hitta_php_package

1. Go to this page and download the library: Download grafstorm/hitta_php_package library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

grafstorm / hitta_php_package example snippets


$hitta = new Hitta('::api-user::', '::api-key::');
$result = $hitta->companies()
    ->what('Empire')
    ->where('Deathstar')
    ->find();

foreach($result->companies as $company) {
    echo $company->displayName . "\n";
}

// Hitta.se API Wrapper as a Laravel Package
// Search for Swedish companies and people

// Create a new instance of the API wrapper.
$hitta = new Hitta('::api-user::', '::api-key::');

// Combined search. You can also explicitly call Hitta::combined()
$hitta->what('Luke Skywalker')
  ->where('Kiruna')
  ->find();
  
$result = $hitta->combined()
  ->what('Empire')
  ->where('Deathstar')
  ->find();

foreach($result->companies as $company) {
  echo $company->displayName . "\n";
}

foreach($result->people as $person) {
  echo $person->displayName . "\n";
}

// Only Search for people
$hitta->people()
  ->what('Luke Skywalker')
  ->find();
  
// Only Search for companies
$hitta->companies()
  ->what('Empire')
  ->find();
  
// Optional search parameters
$hitta->companies()
  ->what('Luke Skywalker')
  ->where('Kiruna')
  ->pageNumber(1)
  ->pageSize(10)
  ->rangeFrom(100)
  ->rangeTo(150)
  ->find();

// Example of Fetching details of a company or person with findPerson and findCompany.
$result = $hitta->combined()
  ->what('Skywalker')
  ->find();
  
$personId = collect($result->people)->first()->id;
$companyId = collect($result->companies)->first()->id;

$hitta->findPerson($personId);
$hitta->findCompany($companyId);