Search code examples
phpgetstream-io

can we get all activity without user ID in getstream


Can we get stream without user id i.e. without $results = $user_feed_1->getActivities(5, 10);

I want to get all streams for all users. Is it possible ?


Solution

  • It is currently not possible to retrieve activities stored on many feeds in a single request. You can only read activities from one feed at the time.

    You can achieve that by sending all activities to a global feed. The suggested way to do this, is to use the to targeting field as documented here: http://getstream.io/docs/#targetting

    For example:

    $userOneFeed = $client->feed('user', '1');
    $data = [
        "actor"=>"user:tommaso",
        "verb"=>"reply",
        "object"=>"question:35312059",
        "to"=>["flat:global"]
    ];
    $userFeedOne->addActivity($data);
    

    this code adds an activity to $userOneFeed and to the global feed. If you add the to field every time you add an activity, you will be able to fetch all activities by reading from the global feed.

    $globalFeed = $client->feed('flat', 'global');
    $globalFeed->getActivities(5, 10);