Giter VIP home page Giter VIP logo

php-api-client's People

Contributors

dudla avatar lwillems avatar magus424 avatar matyx avatar ndottens avatar ondrafiedler avatar ondram avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

php-api-client's Issues

Escaping Method for filter Expressions

we built filter expressions like

        $searchParams = [
            'returnProperties' => true,
            'filter' => '(
                           (\'adaid\' == '.(int) $user->adaid.') AND
                           ( \'active\') 
                        )',
        ];

        $result = $this->client->send(new SearchItems($userid, $searchQuery, self::COUNT_SEARCH_ITEMS, $searchParams));

for this case we need to escape user-input so we can use it in the filter query.
atm this is easy because we just have this int here. but image we would have to pass in a string value.. how should this value be escaped for the filter-expression?

IMO the SDK should provide a escaping method, so we can use whatever variable inside the expresssion without security risks

Batch method and the problem with identifying original request

Hi,
I have a problem. I use us library. I would like to use the batch method. I can not pair original requests on responses. I get only an array without an identification on original request.

Example currently state:

<?php

declare(strict_types=1);

use Recombee\RecommApi\Client;
use Recombee\RecommApi\Requests\Batch;
use Recombee\RecommApi\Requests\SearchItems;

$client = new Client('--my-database-id--', '--db-private-token--');

$requests = [
	new SearchItems(user_id: '12345', search_query: 'test', count: 10),
	new SearchItems(user_id: '12345', search_query: 'test1', count: 10),
	new SearchItems(user_id: '12345', search_query: 'test2', count: 10)
];

$batch = new Batch($requests);

$output = $client->send($batch); // I get only array without reference on some requests

Client hides all connection errors as ApiTimeoutException; can't include previous Exception instance

Even things like an SSL error will report as timeout, which can easily cause confusion when attempting to debug.

ApiTimeoutException, ResponseException, and UnknownOptionalParameterException are also missing backslashes on Exception in their constructors, which prevent one from attempting to pass the previous exception in to help indicate the root problem; PHP will fail expecting an instance of Recombee\ReommApi\Exceptions\Exception which does not exist

Missing info in batch reply

According API documentation when using batch response looks like this

[
  {
    "code": 200,
    "json": "ok"
  },
  {
    "code": 200,
    "json": "ok"
  },
  {
    "code": 200,
    "json": [
      "item-a",
      "item-b",
      "item-c",
      "item-d",
      "item-e"
    ]
  }
]

But when i am using it with multiple setItemsValues, reply looks like this

[
  {
    "json": "ok",
    "code": 200
  },
  {
    "json": "ok",
    "code": 200
  }
]

Last part with my itemId is missing, so i am not able to determine which items are ok and which ones are failed.

Regards,

Support GZIP encoded POSTs/GETs via CURL

we use the API and send between 15k and 40k requests per hour.. things get pretty slow..

we aleady batch the requests to reduce the overhead.

after a bit of investigation it looks like requests/responses are not compressed/gzip-encoded. we only see Accept-Encoding: deflate, gzip but no Content-Encoding: gzip

also when posting items to the webservice it seems things went across the wire in plain text.

see the following output, after hacking curl_setopt($this->handle, CURLOPT_VERBOSE, 1); into the cURL.php of the http-client:

*   Trying 136.243.64.171...
* Connected to rapi.recombee.com (136.243.64.171) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /cluster/www/www/www/telexa/vendor/rmccue/requests/library/Requests/Transport/cacert.pem
  CApath: /etc/ssl/certs
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*        subject: OU=Domain Control Validated; CN=*.recombee.com
*        start date: Dec 30 10:26:13 2018 GMT
*        expire date: Feb 28 16:23:00 2021 GMT
*        subjectAltName: rapi.recombee.com matched
*        issuer: C=US; ST=Arizona; L=Scottsdale; O=GoDaddy.com, Inc.; OU=http://certs.godaddy.com/repository/; CN=Go Daddy Secure Certificate Authority - G2
*        SSL certificate verify ok.
> GET /telexa-dev/items/list/?hmac_timestamp=1585732533&hmac_sign=XXXHTTP/1.1
Host: rapi.recombee.com
Accept: */*
Accept-Encoding: deflate, gzip
Referer: https://rapi.recombee.com/telexa-dev/items/list/?hmac_timestamp=1585732533&hmac_sign=XXX
User-Agent: recombee-php-api-client/3.0.0
Connection: close

< HTTP/1.1 200 OK
< Server: nginx/1.14.1
< Date: Wed, 01 Apr 2020 09:15:33 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 190555
< Connection: close
< X-Recombee-Request-Id: 2100e32cfc2677b0f662f571fccd69ea
< Cache-Control: no-cache
<
* Closing connection 0
DIE!mstaab@mst16:/cluster/www/www/www/telexa/scripts$ php recombee.php partner development 17
start:2020-04-01 11:16:37
*   Trying 136.243.64.171...
* Connected to rapi.recombee.com (136.243.64.171) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /cluster/www/www/www/telexa/vendor/rmccue/requests/library/Requests/Transport/cacert.pem
  CApath: /etc/ssl/certs
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*        subject: OU=Domain Control Validated; CN=*.recombee.com
*        start date: Dec 30 10:26:13 2018 GMT
*        expire date: Feb 28 16:23:00 2021 GMT
*        subjectAltName: rapi.recombee.com matched
*        issuer: C=US; ST=Arizona; L=Scottsdale; O=GoDaddy.com, Inc.; OU=http://certs.godaddy.com/repository/; CN=Go Daddy Secure Certificate Authority - G2
*        SSL certificate verify ok.
> GET /telexa-dev/items/list/?hmac_timestamp=1585732597&hmac_sign=XXXHTTP/1.1
Host: rapi.recombee.com
Accept: */*
Accept-Encoding: deflate, gzip
Referer: https://rapi.recombee.com/telexa-dev/items/list/?hmac_timestamp=1585732597&hmac_sign=XXX
User-Agent: recombee-php-api-client/3.0.0
Connection: close

< HTTP/1.1 200 OK
< Server: nginx/1.14.1
< Date: Wed, 01 Apr 2020 09:16:37 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 190555
< Connection: close
< X-Recombee-Request-Id: 06730ddebc72699bdc2f513d5b3241d0
< Cache-Control: no-cache
<
* Closing connection 0
* Hostname rapi.recombee.com was found in DNS cache
*   Trying 136.243.64.171...
* Connected to rapi.recombee.com (136.243.64.171) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /cluster/www/www/www/telexa/vendor/rmccue/requests/library/Requests/Transport/cacert.pem
  CApath: /etc/ssl/certs
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*        subject: OU=Domain Control Validated; CN=*.recombee.com
*        start date: Dec 30 10:26:13 2018 GMT
*        expire date: Feb 28 16:23:00 2021 GMT
*        subjectAltName: rapi.recombee.com matched
*        issuer: C=US; ST=Arizona; L=Scottsdale; O=GoDaddy.com, Inc.; OU=http://certs.godaddy.com/repository/; CN=Go Daddy Secure Certificate Authority - G2
*        SSL certificate verify ok.
> POST /telexa-dev/batch/?hmac_timestamp=1585732597&hmac_sign=XXXHTTP/1.1
Host: rapi.recombee.com
Accept: */*
Accept-Encoding: deflate, gzip
Referer: https://rapi.recombee.com/telexa-dev/batch/?hmac_timestamp=1585732597&hmac_sign=XXX
Content-Type: application/json
User-Agent: recombee-php-api-client/3.0.0
Connection: close
Content-Length: 658192
Expect: 100-continue

Client did not get response within #1000 ms

Hi

I am getting the following error after installing and setting up the php-api-client via composer:

Fatal error: Uncaught Recombee\RecommApi\Exceptions\ApiTimeoutException: Client did not get response within #1000 ms in /srv/users/sandwichboard/vendor/recombee/php-api-client/src/RecommApi/Client.php:105 Stack trace: #0 /srv/users/sandwichboard/apps/sandwichboard/public/include/config.php(26): Recombee\RecommApi\Client->send(Object(Recombee\RecommApi\Requests\AddDetailView)) #1 /srv/users/sandwichboard/apps/sandwichboard/public/index.php(3): require_once('/srv/users/sand...') #2 {main} thrown in /srv/users/sandwichboard/vendor/recombee/php-api-client/src/RecommApi/Client.php on line 105

This is the code that I am trying to run (haven't changed much from what's in https://docs.recombee.com/gettingstarted.html#getting-started-catalog)

  use Recombee\RecommApi\Client;
  use Recombee\RecommApi\Requests as Reqs;

  $client = new Client( $database, $key );
  $client->send(new Reqs\AddDetailView( "2c169e575644d840838e", "xyz" ) );

Curl empty reply from server

Hello

Got a curl error trying to send an item with setItemValues :

$r = new SetItemValues(
"78909",
$formattedItem,
['cascadeCreate' => true,]
);
$client->send($r);

Here's the json body dump :

{
  "sku": 78909,
  "quantity": 0,
  "hash": "xxxxxx",
  "category": "Coins , France , 1901-2001 , h. 1 franc",
  "categoryPath": "1108.1215.1244.1253",
  "featured": false,
  "price_eur": 8,
  "name_en": "Coin, France, Semeuse, Franc, 1916, Paris, AU(55-58), Silver, KM:844.1",
  "name_fr": "Monnaie, France, Semeuse, Franc, 1916, Paris, SUP, Argent, KM:844.1, Gadoury:467",
  "name_de": "Münze, Frankreich, Semeuse, Franc, 1916, Paris, VZ, Silber, KM:844.1",
  "name_it": "Moneta, Francia, Semeuse, Franc, 1916, Paris, SPL-, Argento, KM:844.1",
  "name_es": "Moneda, Francia, Semeuse, Franc, 1916, Paris, EBC, Plata, KM:844.1, Gadoury:467",
  "name_nl": "Munten, Frankrijk, Semeuse, Franc, 1916, Paris, PR, Zilver, KM:844.1",
  "image_url_1": "https://cdn.shopify.com/s/files/1/0938/5674/products/8744ec3773c4becc1cfb66ea73a3c371.jpeg?v=1464169262",
  "image_url_2": "https://cdn.shopify.com/s/files/1/0938/5674/products/9b0afeddef2a762d92ebb64ed9c5909b.jpeg?v=1464169262",
  "url_en": "https://www.numiscorner.com/products/france-semeuse-franc-1916-paris-au55-58-silver-km-844-1-gadoury-468",
  "url_fr": "https://www.numiscorner.fr/products/france-semeuse-franc-1916-paris-sup-argent-km-844-1-gadoury-467",
  "!cascadeCreate": true
}

When removing some properties response is ok from API, perhaps there is a limitation on body size ?

Regards

Empty json response is evaluated as false

Whenever item-based recommendations are requested with a minimum relevance greater than low, it is possible that the result set is empty.

It seems that this is interpreted as a malformed json here, when it is in fact a valid response.

The client then returns a string type instead of an array, which is unexpected.

No actions being stored

Hi I am using PHP api and have successfully added products and views and received recommendations, when publishing views and add to cart actions, none of these are showing up in the console, in addition, when clicking on a recommended product which sends a view detail, the view details are not showing up, also after a while recommendations return nothing.

View details, add to cart etc all return OK, I see the 2 products and the two users in the console but clicking on them shows none of the actions, actions do not show up on the graphs either.

Support PSR-18

as it stands this lib requires the rmccue/requests http client.

to ease integration into existing applications/frameworks it would be very helpfull if the lib instead would use the PSR18 interfaces instead of a concrete http client.
that way the lib could be used with a already existing http client lib and would not need to add an additional http client to an existing stack.

thats a major pain point when using the lib

https://www.php-fig.org/psr/psr-18/

PHP SDK does not work

Following your documentation here, including installing the client sdk: https://github.com/Recombee/php-api-client

PHP Fatal error: Uncaught InvalidArgumentException: Region is unknown. You may need to update the version of the SDK.

Removing region array results in Uncaught Recombee\RecommApi\Exceptions\ResponseException: {"statusCode":404, "message":"Unable to parse database"} when using the credentials provided in your UI.

FR: Create database via API

Hi guys,
Do you consider add support to create database via API?
Should be helpful for integration recommbee to cloud services.
Thank you.

Composer error

When executing composer require recombee/php-api-client it return error requiring rmccue/requests ^1.7.1 no matching package found (last version 1.7.0).

Any hint?
Thanks in advance,
Carles

root@dev-16-inp-web:/data/recombee-test/php-api-client (master)$ composer require recombee/php-api-client
Using version ^1.3 for recombee/php-api-client
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Can only install one of: recombee/php-api-client[v1.3, dev-master].
    - Can only install one of: recombee/php-api-client[v1.3.2, dev-master].
    - recombee/php-api-client v1.3.1 requires rmccue/requests ^1.7.1 -> no matching package found.
    - Installation request for recombee/php-api-client dev-master -> satisfiable by recombee/php-api-client[dev-master].
    - Installation request for recombee/php-api-client ^1.3 -> satisfiable by recombee/php-api-client[v1.3, v1.3.1, v1.3.2].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Invalid HMAC signature

Trying to use the PHP API client and I'm getting an error when running any command.

[Recombee\RecommApi\Exceptions\ResponseException]
  {"statusCode":401, "error":"Invalid HMAC signature"}

I've set it up exactly how it says in the docs.

$client = new Client(
            config('services.recombee.database'),
            config('services.recombee.token')
        );

$client->send(new AddItemProperty("name", "string"));

I've searched your API docs and it says the APIs take care of the HMAC signature already. Can you help with this issue please?

No able to retrieve recommendations

Trace is:

[2017-09-04 13:38:26] local.nested.net.ERROR: Recombee\RecommApi\Exceptions\ResponseException: {"statusCode":404, "error":"Unknown key or database"}
 in /home/vagrant/Code/vendor/recombee/php-api-client/src/RecommApi/Client.php:167
Stack trace:
#0 /home/vagrant/Code/vendor/recombee/php-api-client/src/RecommApi/Client.php(155): Recombee\RecommApi\Client->checkErrors(Object(Requests_Response))
#1 /home/vagrant/Code/vendor/recombee/php-api-client/src/RecommApi/Client.php(90): Recombee\RecommApi\Client->post('http://rapi.rec...', 3, '{"count":5}')

Batch processing and numeric key

When using Batch() with numeric keys in array body, everything is replaced by other keys due to $params = array_merge($params, $req->getBodyParameters()) in RequestBatchArray() method

So numeric keys can not be used

Regards

Problems while installing the php-api-client 3.1

we are running into problems because of the guzzle dependency in the 3.1 version of this lib.

our dependency graph already contains the guzzle http client and therefore our dependency constraint conflict with those defined in

"guzzlehttp/guzzle": "^7.2.0"

could this package be adapted to use https://github.com/php-http/httplug instead of guzze directly?
httplug is a small abstraction layer - which is also implemented by guzzle - but allows switching the http client in use. that way the recombee php api client would not directly depend on a fixed http client implementation and therefore it would be easier to integrate it into existing applications

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.