Coder Social home page Coder Social logo

getstream / stream-php Goto Github PK

View Code? Open in Web Editor NEW
141.0 39.0 36.0 390 KB

PHP Client - Build Activity Feeds & Streams with GetStream.io

Home Page: https://getstream.io

License: BSD 3-Clause "New" or "Revised" License

PHP 98.84% Dockerfile 0.24% JavaScript 0.92%
php stream activity-feed getstream-io timeline notification-feed news-feed feed

stream-php's Issues

Batcher unfollowMany results in 429 Too Many Requests

Client error: POST https://api.stream-io-api.com/api/v1.0/unfollow_many/?api_key=xxxxxxx resulted in a 429 Too Many Requests

response:

{ "detail": "Too many requests, check response headers for more information.", "status_code": 429, "code": 9, "exception ": "RateLimitReached", "duration ": "0.00 ms " }

I see that the REST Documentation does not have the v1.0/unfollow_many documented. I assume this API endpoint was implemented but has been removed again?

https://github.com/GetStream/stream-php/blob/master/lib/GetStream/Stream/Batcher.php#L91

Use of undefined constant VERSION

Running getstream with Symfony 5.2 on PHP 7.4.

This notice appears frequently:

NOTICE: PHP message: PHP Warning: Use of undefined constant VERSION - assumed 'VERSION' (this will throw an Error in a future version of PHP) in /srv/http/vendor/get-stream/stream/lib/GetStream/Stream/Feed.php on line 67

Best regards.

gz#10568

'Invalid Json Payload' error on updateActivities()

here is the data being posted to updateActivities() method [which is exactly same when new activity is added]

(
[actor] => admin
[verb] => content_published
[object] => Post: Grading Go Bags
[title] => Grading Go Bags
[started_at] => Array
(
[date] => 2018-08-08 13:42:21.000000
[timezone_type] => 3
[timezone] => UTC
)

[status] => new status on activity update is published
[content_url] => This is test url to see if activity can be updated using this way.
[time] => 2018-07-23 14:30:16
[meta] => Array
    (
        [post_type] => post
        [excerpt] => The quality of earthquake survival kits ranges from solid to shaky. We rated several emergency kits on the market to find the survival bag most likely to come in handy when The Big One hits. 
        [category] => TOOLS
        [story_headline] => Getting Ready for the Big One
        [deck_headline] => The quality of earthquake survival kits ranges from solid to shaky
        [author] => Beth Spotswood
        [thumbnail] => Array
            (
                [url] => http://localhost/altaonline.com/wp-content/uploads/2018/06/ATA050118starwars_img01.jpg
                [alt] => 
            )

    )

[foreign_id] => 3798

)

and it says 'Invalid JSON Payload with following trace

PHP Fatal error: Uncaught exception 'GetStream\Stream\StreamFeedException' with message '{"detail":"Invalid JSON payload","status_code":400,"code":4,"exception":"InputException","duration":"0.14ms"}' in C:\wamp64\www\altaonline.com\wp-content\plugins\feed-manager\vendor\get-stream\stream\lib\GetStream\Stream\Feed.php:100

How to enrich reactions

I want to store reactions as a Laravel eloquent object, so I can enrich it.
How to enrich this data from the feed? I added a model reference in the data field, but i'm not sure if it is possible in this way?

Add interfaces for the Feed and the Client

Hi,

I think it should be a great idea to implements interfaces in this project.
We are using the SDK in Symfony, and we are trying to cover our code with some behat tests.
By implementing some interfaces, I could be able to create Dummies of the Feed and the Client objects in my tests.

I Can do a PR for that, do you have any good practice for that? Naming conventions, specific namespace?
I'm also wondering why all the methods are public? Some of them seem to be internal and should be protected/private, no?

All tests are failing

I actually get different test failures/errors when I've pulled it to run it locally, which is interesting. But either way, CI isn't much use if tests fail all the time.

auth naming

secret = the api secret
token = a token for accessing a feed (generated from the secret)
authorization = the header sent for authorization combining the feed name and the token

consistency followFeed

python, js and ruby do it like this

Get the feed object for aggregated 3 and follow user 1

aggregated3 = client.feed('aggregated:3')
aggregated3.follow('user:1')

vs

// Get the feed object for aggregated 3 and follow user 1
$aggregated3 = $client->feed('aggregated:3');
$aggregated3->followFeed('user:1');

Feed slug validation is not consistent with GetStream docs

I am getting a feed_slug validation error with this slug: "user-aggregated".

I was able to create this feed from the dashboard and the docs don't mention much about the naming convention.

Issue at: BaseFeed::validFeedSlug

Exception received: StreamFeedException(feed_slug can only contain alphanumeric characters or underscores)

JWT Version Again

Could you please bump JWT Version again?

  • get-stream/stream[5.0.0, ..., 5.0.2] require firebase/php-jwt ^v5.0.0 -> found firebase/php-jwt[v5.0.0, ..., v5.5.1] but the package is fixed to v6.8.1 (lock file version)

Attempted to call function "parse_query"

I am getting this error

Attempted to call function "parse_query" from namespace "GuzzleHttp\Psr7".

I guess I am running the correct versions of Guzzle:

/app# composer info | grep guzzle
guzzlehttp/guzzle                        7.3.0     Guzzle is a PHP HTTP c...
guzzlehttp/promises                      1.4.1     Guzzle promises library
guzzlehttp/psr7                          2.0.0     PSR-7 message implemen...

The PSR7 Repo says that the parse_query has been replaced by Query::parse.

Can't log request/response to file

For debugging I'd like to be able to log out all requests and responses from the Stream API to a file, would it be possible to expose the Guzzle client in some way so we can add additional log handlers, etc?

Mark Seen option does not accept an array

More of an inconsistency than anything else, but when passing options to a notification feed, the documentation states the same for both mark_seen and mark_read:

NAME        DESCRIPTION
mark_read   Comma separated list of activity ids to mark as read, or boolean true
mark_seen   Comma separated list of activity ids to mark as seen, or boolean true

And the code example given shows this being achieved with an array rather than a string:

# Mark some activities as read
$options = array('mark_read' => array('activity_id_1', 'activity_id_2'));
$results = $notification_feed->getActivities(0, 10, $options);

This works fine for mark_read but does not work for mark_seen. I believe both should behave the same way.

Batch upsert collection fails with "error parsing 'data'"

Expected Behavior

Example was copied directly from official documentation

Performing upsert() with an array of arrays should batch insert/update many collection items.

Actual Behavior

Exception is thrown:

Type:        GetStream\Stream\StreamFeedException
Message:     {"detail":"Error parsing 'data'","status_code":400,"code":4,"except
ion":"InputException","exception_fields":{"data":["Error parsing 'data'"]},"dura
tion":"0.16ms"}

Steps to Reproduce the Problem

  1. Install and configure the stream-php library as described in documentation Quickstart
  2. Paste example code from Batch Endpoint documentation
$client->collections()->upsert('visitor', [
    [
        'id' => '123',
        'username' => 'johndoe',
        'favorite_color' => 'blue',
    ]
]);
  1. Execute code and exception is thrown.

Troubleshooting

  • Tried JS example code which works successfully (ruling out account-specific issues)
  • JS lib posts to "collections/" endpoint and PHP lib to "meta/" (Collections.php line 178)
  • PHP lib encapsulates "data" in an array resulting in batch requests having an "extra" array compared to the JS code.
  • Removing the extra array causes non-batch requests to fail.

Solution

I did not create a pull request because this solution is not something I've put a lot of thought into regarding performance or compatibility, it's just good enough to work.

public function upsert($collectionName, array $data)
    {
        $shouldBatch = array_filter($data, 'is_array') === $data;

        $response = $this->doRequest('POST', 'collections/', ['data' => [$collectionName => $shouldBatch ? $data : array($data)]]);
        $body = $response->getBody()->getContents();
        return json_decode($body, true);
    }

Specifications

  • Version: 3.0.0
  • Platform: PHP 7.0.33, Linux, Nginx

Restrictive package requirements of Guzzle

Guzzle is required, but is specified to be as follows:

"guzzlehttp/guzzle": "6.0.*"

Instead, given that Guzzle follows Semantic Versioning, could this please be changed to the following to ensure maximum compatibility when integrating with large projects?

"guzzlehttp/guzzle": "^6.0"

Erro trying to make a request to a https url

Hi,

I'm trying to make a request to this url https://www.whoscored.com/?t=Hart, but I'm getting the following error:

Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 60: SSL certificate problem: self signed certificate in certificate chain (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in C:\xampp5.6\htdocs\comuniazo-uk\api\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:187 Stack trace: #0 C:\xampp5.6\htdocs\comuniazo-uk\api\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(150): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 C:\xampp5.6\htdocs\comuniazo-uk\api\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(103): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #2 C:\xampp5.6\htdocs\comuniazo-uk\api\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFa in C:\xampp5.6\htdocs\comuniazo-uk\api\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 187

I know of course is related with the SSL connection, but I'm kind of lost in this aspect. I've made some search over the internet, but I haven't found a solution for the problem.

Could you help me with this? Some guide on how to solve the problem...

This is the code that make the request:

$client = new Client();

$url = 'http://www.whoscored.com/Search/?t=' . $player["name"];

$crawler = $client->request('GET', $url);

Is there anyway to make the call without a cert?

ERROR - The request could not be satisfied same as MaxTiago's

Hi Guys,

I am getting this cloudfront error similar to MaxTiago's. But I can't seem to fix it. I am assuming, based on MaxTiago's comment, that we need to have our VPS server bind to listen all:

listen-on { any; };
listen-on-v6 { any; };

but it is still not working. Works perfectly on my local machine (XAMPP) as well as our test server in Heroku, but not on our VPS server.

Time Parameter For Batch Methods

My Acitity
foreign_id - activity:1
time - 2021-04-04T05:47:16.065221Z

$results = $this->client->getActivities(null, [[
'activity:1',
Carbon::parse("2021-04-04T05:47:16.065221Z"),
]]);

If i pass time as "2021-04-04T05:47:16.065221Z", I got "Call to a member function format() on string" error.
So i pass like that "Carbon::parse("2021-04-04T05:47:16.065221Z")"
But i can't get activity because of the wrong time.

I see getstream php library format the time like that.
$times[] = $fit[1]->format(DateTime::ISO8601);
It returns 2021-04-04T10:27:25+0000

If i change your code like below, i can retrieve.
$times[] = $fit[1]->format('Y-m-d\TH:i:s.u');

gz#10834

Error dsiplay while connecting from client to server in zimbra api

Fatal error: Uncaught exception 'GuzzleHttp\Exception\ServerException' with message 'Server error response [url] https://10.10.2.32:7071/service/admin/soap [status code] 500 [reason phrase] Server Error' in /home/vikatan/www/intrasite/intra.vikatan.com/zimbra/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:89 Stack trace: #0 /home/vikatan/www/intrasite/intra.vikatan.com/zimbra/vendor/guzzlehttp/guzzle/src/Subscriber/HttpError.php(33): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Message\Request), Object(GuzzleHttp\Message\Response)) #1 /home/vikatan/www/intrasite/intra.vikatan.com/zimbra/vendor/guzzlehttp/guzzle/src/Event/Emitter.php(108): GuzzleHttp\Subscriber\HttpError->onComplete(Object(GuzzleHttp\Event\CompleteEvent), 'complete') #2 /home/vikatan/www/intrasite/intra.vikatan.com/zimbra/vendor/guzzlehttp/guzzle/src/RequestFsm.php(91): GuzzleHttp\Event\Emitter->emit('complete', Object(GuzzleHttp\Event\CompleteEvent)) #3 /home/vikatan/www/intrasite/intra.vikatan.com/zimbra/vendor/guzzlehttp/ in /home/vikatan/www/intrasite/intra.vikatan.com/zimbra/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 89

Please help me all.

Error when making call from client to server

Fatal error: Uncaught exception 'GuzzleHttp\Ring\Exception\RingException' with message 'cURL error 60: SSL certificate problem: self signed certificate in certificate chain' in C:\workspace\app\vendor\guzzlehttp\ringphp\src\Client\CurlFactory.php:126 Stack trace: #0 C:\workspace\app\vendor\guzzlehttp\ringphp\src\Client\CurlFactory.php(90): GuzzleHttp\Ring\Client\CurlFactory::createErrorResponse(Object(GuzzleHttp\Ring\Client\CurlHandler), Array, Array) #1 C:\workspace\app\vendor\guzzlehttp\ringphp\src\Client\CurlHandler.php(78): GuzzleHttp\Ring\Client\CurlFactory::createResponse(Object(GuzzleHttp\Ring\Client\CurlHandler), Array, Array, Array, Resource id #68) #2 C:\workspace\app\vendor\guzzlehttp\ringphp\src\Client\Middleware.php(54): GuzzleHttp\Ring\Client\CurlHandler->__invoke(Array) #3 C:\workspace\app\vendor\guzzlehttp\ringphp\src\Client\Middleware.php(30): GuzzleHttp\Ring\Client\Middleware::GuzzleHttp\Ring\Client{closure}(Array) #4 C:\workspace\app\vendor\guzzlehttp\guzzle\src\RequestFsm.php(129): GuzzleHttp\Ring\Cli in C:\workspace\app\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php on line 51

I would appreciate if you could help me get around this error

Add child reaction fail with {"detail":"Error parsing 'target_feeds'","status_code":400,"code":4,"exception":"InputException","exception_fields":{"ta (truncated...)

Steps to reproduce
Add child reaction with target_feed array parameter.

Current Behavior
When i am adding child reaction with target_feed, it returns this error. That i think, in the addChild function which is converting target_feed array to comma separated string. Like this
if( $targetFeeds !== null ){
$payload['target_feeds'] = join(',', $targetFeeds);
}
if i change to this
$payload['target_feeds'] = $targetFeeds;
It is working fine.

Replace abandoned packages

Hi,

I see that this project is using 3 abandoned packages:

  • phpunit/phpunit-mock-objects
  • guzzle/guzzle
  • satooshi/php-coveralls

Do you plan to upgrade those dependencies? Do you need help with that?

Guzzle 6.0 Issue

Message: Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, string given, called in /vendor/guzzlehttp/guzzle/src/Client.php on line 87 and defined

expose signing

the readme and code should explain how to generate a token for usage in the client side API

ERROR - The request could not be satisfied

Type: GetStream\Stream\StreamFeedException
Message: ERROR The request could not be satisfied (bad request)

Generated by cloudfront (CloudFront)

Filename: .../vendor/get-stream/stream/lib/GetStream/Stream/Feed.php
Line Number: 102

I'm getting this exception when fetching some activities on testing setup (ubuntu, apache 2.4.7, php 7.0.8)
The same code works fine on my local setup (windows, xampp -> php 7.0.6)

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.