PHP code example of headzoo / prediction-io

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

    

headzoo / prediction-io example snippets




$client = new Endroid\PredictionIO\PredictionIO($appKey, $apiUrl);

// populate with users, items and actions
$client->createUser($userId);
$client->createItem($itemId);
$client->recordAction($userId, $itemId, 'view');

// get recommendations and similar items
$recommendations = $client->getRecommendations($userId, $engine, $count);
$similarItems = $client->getSimilarItems($itemId, $engine, $count);