Can we get previous tweet using Twitter Streaming API? - php

I am working with Twitter REST API [PHP] for a month. Now I try STREAMING API because REST API has several downsides.
I use fennb/phirehose to work with Streaming API.
But after several trial and error, I realise that I can't got past/previous tweets using Streaming API.
I run the script
I post tweet
console/cmd will catch my tweet immediately
I stop the script
I post tweet
I run the script
console not return any result.
The problem is, in programming and server, sometimes shit happen. Let's call it server down or lost internet connection. I will never get all previous tweet which posted when my server down. (I have 40 search term and more later).
So. i wanna ask:
Can we get previous tweet using Streaming API?
How to prevent/solve this case (console throw error, server restart, internet down, etc)?

Twitter's basic streaming API is realtime and about 1% of the actual firehouse of Tweets. You cannot retrieve older Tweets via the stream, and would need to fallback to the basic REST API to check for anything missed in the event of disconnection.
Twitter's enterprise data APIs include historical PowerTrack which can let you get older Tweets, as well as a replay capability in the event of disconnection, but these APIs are commercial.

Related

PHP multiple events sending

I`m working on application which prviding clients to use calendar and creating some events there (I mean calendar in my app). Some of clients are have more than 1000 events in calendar and I want to start using Google Calendar . But I cant find any way to send multiple events in Google Calendar by 1 request.
Question: Is it possible to send few events in 1 request by using php-sdk, which google provides or by any other way such a http request?
Upd: I saw batch requests in google calendar docs, but Im not sure that its working now and how do I need to use it
Thanks!
The method you would be using is events.insert this method Creates an event as in singular there is no way to send a request that would send more than one.
You could use batching but all batching really is is sending X number of event.inserts in a single batch request. Its not going to save you on quota the quota cost will be the same the only thing it will save you on is on the number of HTTP calls you are making.
Global HTTP Batch Endpoints (www.googleapis.com/batch) will cease to work on August 12, 2020 as announced on the Google Developers blog. For instructions on transitioning services to use API-specific HTTP Batch Endpoints (www.googleapis.com/batch/api/version), refer to the blog post.
The above statment does not mean that batching doesnt work. It just means that the old batching endpoint which worled for every API no longer works now you need to send batching requests to each api
www.googleapis.com/batch/drive/v3
www.googleapis.com/batch/calendar/v3
you used to be able to send all batching requests no matter what api you were working with to
www.googleapis.com/batch
That no longer works.

Push transactions to Google Analytics using php

I need to push offline transactions to Google Analytics.
I am thinking of creating a php script that queries the ecommerce database looking at transactions made in the last hour created from the backend. Having identified these transactions (and line items/SKU's).
How do I use PHP to push data to Google Analytics?
You need to go though the measurement protocol. There is no client library to help you do this in PHP you will have to code it yourself. That being said its not that hard its just a normal HTTP Post or HTTP Get request. The trick is building up your requests correctly.
A couple of quick tips.
Qt stands for que time and will allow you to set the time that the hit arrived on your server. Note it must not be greater than four hours ago.
While you are testing this you can use the debug endpoint to validate your hits. The hits wont be sent to Google but it will tell you if they are valid or not.
Measurement Protocols as #DaImTo mentioned is the answer. make a try here replacing the UA Id -
https://ga-dev-tools.appspot.com/hit-builder/?v=1&tid=UA-XXXXX-Y&cid=555&t=transaction&ti=12345&ta=westernWear&tr=50.00&ts=32.00&tt=12.00&cu=EUR
You can use DIv tool to validate all your post requests.
(dont forget to enable - ecommerce from view settings in GA when testing on new account)

Twitch API Live Callback Service

I am integrating the Twitch user account API into my platform and had a look through the API to see if there was a callback section of some sort to send an update to my server when a user starts streaming, but I can't seem to find any reference for one.
Is there currently any services that offer this sort of thing? If not, what would be the best way of running regular checks on all of my users in my Database to see when they are streaming, of course doing this alone would kill the server with database queries, so I'm stuck as to where to go now.
What I am looking to do is receive a callback and then create a post in a social feed that the user has started streaming.
Based on the discussions at the links below, the API doesn't support webhooks and won't anytime soon. Instead, they expect you to use polling. Basically you would set up a worker process that makes requests periodically, such as every five minutes, then creates appropriate social feed posts, etc. You can batch them together if you have a bunch of channels to check (exaple from from the github issue):
https://api.twitch.tv/kraken/streams?channel=riotgames,dota2ti,machinima,esltv_hearthstone
https://github.com/justintv/Twitch-API/issues/211
https://discuss.dev.twitch.tv/t/notifications-using-twitch-api-and-php/1009

how to get notification when someone posts a tweet using twitter api and php

I want to save the notification from specific user in friend list in mysql database using php and twitter api
Twitter has two main APIs. HTTP REST and Stream API so you could do that two ways but I think PHP is only suitable for HTTP API since PHP is not multithreaded.
With PHP and cURL extension you could periodically poll the HTTP Twitter API to look for changes on user you are following.
I would use the Stream API which already has a Java client implemented by Twitter staff that works like a charm and receives the updates in RT. For further details:
REST API:
https://dev.twitter.com/rest/public
Streaming API
https://dev.twitter.com/streaming/overview
Hosebird (Streaming client by Twitter)
https://github.com/twitter/hbc
Hope it helps
The Twitter Account Activity API appears to be the way to do this, now.
"The Account Activity API - All Activities (beta) delivers realtime access to all activities related to a Twitter account via webhooks."
https://developer.twitter.com/en/docs/accounts-and-users/subscribe-account-activity/overview

how to use google feed api to detect feeds updates

Because I run a blog aggregator website which checks a large list of RSS feeds for new posts every hour so I will be happy if its possible to use google feed api or Google AJAX Feed API instead of making the cron jobs to read the whole feed to know if its updated or not.
like this link text
You can use the Google Feed API, however instead of polling the feed source every hour you will still need to poll the google feed API every hour. It doesn't notify you of feed updates. If you want to be notified when to update feeds, then you should look into using a ping server, http://en.wikipedia.org/wiki/Ping_blog to determine when feeds are updated so that you know it is time to fetch the feed again. Not all feeds use a ping server, but it might help you for those that do.
As Nanek said, the Google Feed API won't notify you when a feed is changed... for this you'll have to use the PubSubHubbub protocol or services like Superfeedr which is a Google Feed API alternative.

Categories