Last active
December 24, 2015 22:59
-
-
Save predictioniogists/6876188 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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