Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save predictioniogists/6876188 to your computer and use it in GitHub Desktop.
Save predictioniogists/6876188 to your computer and use it in GitHub Desktop.
<?php
// Assuming we already have an ItemSim engine named 'similarapps'
// Get a list of previous viewed app IDs for the current session
$previouslyViewedApps = getViewedAppsInThisSession();
$similarApps = array();
try {
// Retrieve similar apps for each previously viewed app
foreach ($previouslyViewedApps as $app) {
$command = $client->getCommand(
'itemsim_get_top_n',
array(
'pio_iid' => $app,
'pio_engine' => 'similarapps',
'pio_n' => 10
)
);
$result = $client->execute($command);
array_push($similarApps, $result["pio_iids"]);
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
}
// Randomly pick and show 10 similar apps
show(array_rand($similarApps, 10));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment