Comments (2)
The Bayuex client takes care of it all for you. You only need to create the client, add the extensions you want, subscribe a consumer to a channel and then start the client.
Here's a quick example:
<?php
$streamingClient = new BayeuxClient(
new LongPollingTransport(),
new OAuthProvider(
getenv("SF_CLIENT_ID"),
getenv("SF_CLIENT_SECRET"),
getenv("SF_LOGIN_URL"),
getenv("SF_USER"),
getenv("SF_PASS")
)
);
$streamingClient->addExtension(new ReplayExtension(ReplayExtension::REPLAY_SAVED));
// Creates a new channel with the client if one does not exist already
$channel = $streamingClient->getChannel('/topic/Accounts');
// Subscribe a consumer to the channel
$channel->subscribe(
Consumer::create(
function (ChannelInterface $channel, Message $message) {
$data = $message->getData();
$sobject = $data->getSobject();
// Do something with the object
$replayId = $data->getEvent()->getReplayId();
}
)
);
// When you start the client, all defined channels make a subscribe call to Salesforce after the handshake
// When the channel receives a message from Salesforce, all consumers that have subscribed
// to the channel are fired in order of their priority
// This will run forever or until you stop it
$streamingClient->start();
from salesforce-rest-sdk.
I have a similar question. If I want to manually specify the Replay ID, I seem to not able to do this. Can you advise? I assumed $channel->addExtension(new ReplayExtension(<REPLAY_ID_HERE>));
would work.
from salesforce-rest-sdk.
Related Issues (20)
- Getting strange errors for all calls I make HOT 11
- Topic-level Extensions for the Streaming API
- Issue regarding topic subscribing HOT 2
- having trouble autoloading JMS package HOT 3
- Manually specify the Replay ID HOT 1
- Optional normalizeFieldName?
- Symfony 5 support HOT 2
- Packagist Support HOT 2
- Annotation error with Streaming API
- Runtime exception with Streaming API HOT 2
- Trouble with Replay Extension HOT 3
- Library license
- Possible to return SF response when Persisting object?
- trouble with streaming client
- Fatal Error When Running project HOT 4
- PHP 8 support HOT 3
- curl SSL certificate error HOT 1
- Can't unsubscribe after subscribe.
- how to increase results query? I need to get more than 1000..
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from salesforce-rest-sdk.