Created
October 9, 2013 21:08
-
-
Save predictioniogists/6908425 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 | |
// Use Composer's autoloader to load PredictionIO PHP SDK. | |
require_once("vendor/autoload.php"); | |
use PredictionIO\PredictionIOClient; | |
// In the beginning of your application, you need to instantiate the PredictionIO client object. | |
// You need this client object to import data into PredictionIO and retrieve prediction results. | |
// Add this line to the place where you do initialization: | |
$client = PredictionIOClient::factory(array("appkey" => "your app key")); | |
// Add the following code snippets to your application logic respectively: | |
// When a new user registers: | |
$command = $client->getCommand('create_user', array('pio_uid' => "new user id")); | |
$response = $client->execute($command); | |
// When a new app registers: | |
$command = $client->getCommand('create_item', array('pio_iid' => "new app id", 'pio_itypes' => "app")); | |
$response = $client->execute($command); | |
// When a user logs in: | |
$client->identify("the logged-in user ID"); | |
// When a logged-in user views an app: | |
$client->execute($client->getCommand( | |
'record_action_on_item', | |
array('pio_action' => 'view', 'pio_iid' => "the viewed app id") | |
)); | |
// When a logged-in user rates an app: | |
// the variable $rating stores the rating value (from 1 to 5) | |
$client->execute($client->getCommand( | |
'record_action_on_item', | |
array('pio_action' => 'rate', 'pio_iid' => "the rated app id", 'pio_rate' => $rating) | |
)); | |
// When a logged-in user pays for an app: | |
// Use built-in action "conversion" to represent the "pay" action | |
$client->execute($client->getCommand( | |
'record_action_on_item', | |
array('pio_action' => 'conversion', 'pio_iid' => "the paid app id") | |
)); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi sir, plz tell me how to create new user register and add items, view items...