Skip to content

Commit a1a798f

Browse files
committed
Fixed handling of timeout on connecting to the API
1 parent 9343e67 commit a1a798f

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ or
1717
```
1818
{
1919
"require": {
20-
"recombee/php-api-client": "^1.3"
20+
"recombee/php-api-client": "^1.3.1"
2121
}
2222
}
2323
```
@@ -59,7 +59,7 @@ try
5959

6060
echo 'Recommended items: ' . implode(',',$recommended) . "\n";
6161
}
62-
catch(Ex\ApiTimeoutException $e)
62+
catch(Ex\ApiException $e)
6363
{
6464
//use fallback
6565
}

src/RecommApi/Client.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ public function send(Requests\Request $request) {
9090
catch(\Requests_Exception $e)
9191
{
9292
if(strpos($e->getMessage(), 'cURL error 28') !== false) throw new ApiTimeoutException($request);
93+
if((strpos($e->getMessage(), 'cURL error 7') !== false) && (strpos($e->getMessage(), 'timed out') !== false))
94+
throw new ApiTimeoutException($request);
9395
if(strpos($e->getMessage(), 'fsocket timed out') !== false) throw new ApiTimeoutException($request);
96+
9497
throw $e;
9598
}
9699

src/RecommApi/Requests/ItemBasedRecommendation.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ class ItemBasedRecommendation extends Request {
2626
* @var string $target_user_id ID of the user who will see the recommendations.
2727
* Specifying the *targetUserId* is beneficial because:
2828
* * It makes the recommendations personalized
29-
* * Allows calculations of Actions and Conversions in the graphical user interface, as Recombee can pair the user who got recommendations and who afterwards viewed/purchased an item.
29+
* * Allows the calculation of Actions and Conversions in the graphical user interface,
30+
* as Recombee can pair the user who got recommendations and who afterwards viewed/purchased an item.
31+
* For the above reasons, we encourage you to set the *targetUserId* even for anonymous/unregistered users (i.e. use their session ID).
3032
*/
3133
protected $target_user_id;
3234
/**
@@ -50,7 +52,7 @@ class ItemBasedRecommendation extends Request {
5052
*/
5153
protected $cascade_create;
5254
/**
53-
* @var string $scenario Scenario defines a particular application of recommendations. It can be for example "homepage" or "cart". The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
55+
* @var string $scenario Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
5456
*/
5557
protected $scenario;
5658
/**
@@ -127,7 +129,9 @@ class ItemBasedRecommendation extends Request {
127129
* - Description: ID of the user who will see the recommendations.
128130
* Specifying the *targetUserId* is beneficial because:
129131
* * It makes the recommendations personalized
130-
* * Allows calculations of Actions and Conversions in the graphical user interface, as Recombee can pair the user who got recommendations and who afterwards viewed/purchased an item.
132+
* * Allows the calculation of Actions and Conversions in the graphical user interface,
133+
* as Recombee can pair the user who got recommendations and who afterwards viewed/purchased an item.
134+
* For the above reasons, we encourage you to set the *targetUserId* even for anonymous/unregistered users (i.e. use their session ID).
131135
* - *userImpact*
132136
* - Type: float
133137
* - Description: If *targetUserId* parameter is present, the recommendations are biased towards the user given. Using *userImpact*, you may control this bias. For an extreme case of `userImpact=0.0`, the interactions made by the user are not taken into account at all (with the exception of history-based blacklisting), for `userImpact=1.0`, you'll get user-based recommendation. The default value is `0.1`
@@ -145,7 +149,7 @@ class ItemBasedRecommendation extends Request {
145149
* - Description: If item of given *itemId* or user of given *targetUserId* doesn't exist in the database, it creates the missing enity/entities and returns some (non-personalized) recommendations. This allows for example rotations in the following recommendations for the user of given *targetUserId*, as the user will be already known to the system.
146150
* - *scenario*
147151
* - Type: string
148-
* - Description: Scenario defines a particular application of recommendations. It can be for example "homepage" or "cart". The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
152+
* - Description: Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
149153
* - *returnProperties*
150154
* - Type: bool
151155
* - Description: With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying of the recommended items to the user.

src/RecommApi/Requests/UserBasedRecommendation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class UserBasedRecommendation extends Request {
3939
*/
4040
protected $cascade_create;
4141
/**
42-
* @var string $scenario Scenario defines a particular application of recommendations. It can be for example "homepage" or "cart". The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
42+
* @var string $scenario Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
4343
*/
4444
protected $scenario;
4545
/**
@@ -125,7 +125,7 @@ class UserBasedRecommendation extends Request {
125125
* - Description: If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows for example rotations in the following recommendations for that user, as the user will be already known to the system.
126126
* - *scenario*
127127
* - Type: string
128-
* - Description: Scenario defines a particular application of recommendations. It can be for example "homepage" or "cart". The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
128+
* - Description: Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
129129
* - *returnProperties*
130130
* - Type: bool
131131
* - Description: With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying of the recommended items to the user.

0 commit comments

Comments
 (0)