PHP code example of aamortimer / woopra

1. Go to this page and download the library: Download aamortimer/woopra 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/ */

    

aamortimer / woopra example snippets


// setup namespace
use aamortimer\Woopra\Woopra;

// get all the labels that have been setup
Woopra::getAllLabels(array('app-id'=>'', 'secret-key'=>'', 'website'=>''), function($labels){
  print_r($labels);
});

// you can also return data from the function rather then using a callback
$labels = Woopra::getAllLabels(array('app-id'=>'', 'secret-key'=>'', 'website'=>''));

// get all user labels
// search parameter should be an email address or session id
Woopra::getUserLabels(array('app-id'=>'', 'secret-key'=>'', 'website'=>'', 'search'=>''), function($labels){
  print_r($labels);
});

// you can also return data from the function rather then using a callback
$labels = Woopra::getUserLabels(array('app-id'=>'', 'secret-key'=>'', 'website'=>'', 'search'=>''));

// setup namespace
use aamortimer\Woopra\Search;

// set up the search class
$search = new Search(array(
  'app-id' => 'YOUR APP ID HERE',
  'secret-key' => 'YOUR SECRET KEY HERE'
));

// user data
$website = 'example.com';

// search all data for domain
$rsp = $search->search(array(
  'website'=>$website
));
print_r($rsp);

// search by name
$rsp = $search->search(array(
  'website'=>$website,
  'search'=>'Bob Marley'
));
print_r($rsp);

// look up a profile
$rsp = $search->profile(array(
  'website'=>$website,
  'email'=>'[email protected]'
));
print_r($rsp);

// profile visits
$rsp = $search->profileVisits(array(
  'website'=>$website,
  'email'=>'[email protected]',
  'start_day'=>date('Y-m-d', strtotime('- 10 days')),
  'end_day'=>date('Y-m-d')
));
print_r($rsp);

// edit profile data
$rsp = $search->profileEdit(array(
  'website'=>$website,
  'email'=>'[email protected]',
  'data'=>'{"name":"john smith", "age": 33}'
));
print_r($rsp);

// online count
$rsp = $search->onlineCount(array(
  'website'=>$website
));
print_r($rsp);

// setup namespace
use aamortimer\Woopra\userData;

// set up the search class
$labels = new UserData(array(
  'app-id' => 'YOUR APP ID HERE',
  'secret-key' => 'YOUR SECRET KEY HERE'
));

$rsp = $labels->show(array(
  'website'=>'example.com'
));

// setup namespace
use aamortimer\Woopra\Analytics;

// set up the search class
$analytics = new Analytics(array(
  'app-id' => 'YOUR APP ID HERE',
  'secret-key' => 'YOUR SECRET KEY HERE'
));


// get report
$report = [
  'group_by'=>array(
    array('key'=>'time', 'scope'=>'visits')
  ),
  'columns'=>array(
    array('name'=>'People', 'method'=>'count', 'scope'=>'visitors'),
    array('name'=>'Actions', 'method'=>'count', 'scope'=>'actions')
  )
];

$this->analytics->report(array(
  'website' => 'example.com',
  'report' => $report,
  'start_day'=>date('Y-m-d', strtotime('-1 Day')),
  'end_day'=>date('Y-m-d')
));

# Install Composer
curl -sS https://getcomposer.org/installer | php

# Add Woopra as a dependency

composer