Poloniex push api - php

I am interested in writing some basic php to interface with the Poloniex push api.
Their website provides the following info:
https://poloniex.com/support/api/
A php wrapper can be found here:
http://pastebin.com/iuezwGRZ
From what i can determine there are three APIs being push, public and trading. The public and trading APIs provide functions that can be passed parameters etc. The push api stumps me totally as i cannot determine how it works.
The first link above states the API pushes live data and different feeds can be subscribed to.
My questions are:
A) How can php receive a live stream of data?
B) How do i subscribe to a feed?
I may have misunderstood the oush api and my apologies in advance if this is the case.
Edit1:
I believe i need a WAMP client to connect to a WAMP router such as Minion.
https://github.com/Vinelab/minion
Edit2:
Node.js example
http://pastebin.com/dMX7mZE0

The push API is based on Websocket protocol.
Initially you need first to make a connection to the websocket server,
after that you need to register to a data stream (price update stream for example), after that as soon as the server make an update to something (a price ), all connected clients who where previously registred to it will synchronously received the updated price
Finally you got the last price without the need of doublecheck at regular interval if the price has changed

Related

Google Calendar APIv3 - how to handle incoming resource change notification using webhook?

Using Google APIv3 I wish to synchronize my PHP webapp calendar with Google Calendar by creating a notification channel using a webhook on my server. As per the documentation of Google I did the necessary preparations (defining and validating webhook, creating the notification channel) in order to receive status update information from the Calendar using the watch method.
My issue is that I cannot figure out what to do with the incoming information - as per my understanding and as stated in these docs, my webhook should be notified not only about the fact of change, but it should get the actual change as well so I can avoid unnecessary processing. Unfortunately, the know-how on receiving these notification are quite vague and I cannot find where to look for the nature of change made to the Calendar resource.
Am I missing something? Do I have to get the resource using the identifier returned to the webhook and "manually" check differences or there is some technique I can use to update (or even more preferred patch, but I also do not understand how to do that in PHP) the changed Calendar resource on my webapp side? Is PHP even a suitable language to implement this?

How to build a basic web app on WordPress site using AWS API Gateway

I want to build a simple Software-as-a-service web application that performs web scraping - the result per execution will be a table of results with several rows and columns. For the front-end, I wanted to build the website using WordPress since I am familiar with making basic websites there and like the plugins available. For the backend I plan on using AWS Lambda to perform the task serverless-ly. The user will log in to the site, then when they want to use the service will enter some keywords via a form, and that will send HTTP request to AWS API Gateway, which is connected to my Lambda function. Currently, the AWS Lambda function writes results into AWS DynamoDB as it goes - perhaps I need to write a second HTTP request method to query the results, or return the results in the same method that scrapes them instead.
Even after hours of googling, there are several areas in which I am unsure how to proceed, or if I have chosen the right path (I have no prior experience in this area.) Two of the biggest puzzles I have currently though are:
How can I use WordPress to send data to AWS API Gateway? Do I need to write some PHP code and if so what does it look like and where should I put it?
How can I present the results on WordPress site for the user? Should I keep the results saved on DynamoDB and query them when I want to present them, or should I store the results on the WordPress database? Ideally they would see a big table and have options to export to CSV, for example.
Thanks for your help and patience.
Cheers,
jack
There are a couple of possible ways this can be accomplished. One way is to just use webhooks. Most form plugins come with the option to use webhooks and doing it this way is pretty straightforward. Here is an article from WPForms on how to configure it WPForms and Webhooks. Below is an example of how I have used it. The example shows a form that sends data to AWS API Gateway which triggers AWS StepFunctions and also puts the customer information in DynamoDB
WPForms Webhook to AWS API Gateway

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 implement dynamic chat application in Ios using php, Something related to Skype like application

I am trying to implement a chat application in IOS. In general We use two php files one for posting a message(sender) another for retrieving the message(receiver).
I want to accomplish the following:
Consider A(sender) and B (Receiver).
A sent message to B. And A is waiting for B's reply. So i need to call post-api.php for sending a message and at the receivers side(B) i need to retrieve using getapi.php
when B reply to A it must automatically appear in my inbox(live chatbox) of A, without calling getapi.php. I know this scenario is not possible. But is there any solution or method so that my chat application works like skype or facebookchat.
There is multiple way to implement the chat functionality.
Polling: Send request to server and process the response from the server in timely fashion after a particular time interval using NSTimer(But remember is will cause the battery drain).
Using APNS: Using the official Apple push notification implementation, whenever there is new entry in chat table on server side send the notification to particular device using push notification and handle the notification using the delegate methods (Although not 100% reliable).Using Push Notification
Using Socket Programming: Using the socket programming you can have dedicated connection between client(device) and server. I have provided the link having the source at the end of the tutorial.Using Socket Programming
As you know that without getapi.php it is not possible to update chat list so you need to make management something like: you need to use NSTimer and with the help of timer you need to call your getapi.php service after certain time interval let say after 2min so that chat can be refresh and user get the reply this is the only possible way at my knowledge.

Categories