Not Receiving Proper Subscription Messages from Pub/Sub - notifications

I am trying to retrieve subscription information from Google when I receive a Real Time Notification from Google Pub/Sub. Google Pub/Sub is sending me subscription token in this format:
{"message":{"data":"REALLY LONG STRING","messageId":"468103560112704","message_id":"468103560112704","publishTime":"2019-03-18T17:19:01.444Z","publish_time":"2019-03-18T17:19:01.444Z"},"subscription":"my/pubsub/subscriptions/path"}
I don't believe that this is the format that a subscription token is supposed to arrive in, and when I send it to Google to retrieve information using an HTTP GET command, I get nothing, no errors and no data. I think that it is just a generic message. I would think that I am doing everything right because I am actually getting messages when I expect to get them during testing, I just can't do anything useful with them. Any thoughts at all on how to get these converted to REAL messages???

This one took far to long to figure out, and the solution turned out to be quite simple. I was surprised that for two weeks, nobody at Google could find an answer to this question for me. It turns out that this is the correct format for the Pub/Sub message. The JSON message that I was receiving from PubSub was in a VERY different format from what I was expecting based on the Google Play documentation, and basically just had a "data" field that looked like a token, but it wasn't. I actually had to dive into the PubSub documentation deep and found an obscure note on the "data" field - it is a base64 encoded string. If you decode the "data" field, voila!, you get a JSON string containing the subscription purchaseToken that you need to query Google Play for subcription information.
So there is a JSON message INSIDE of this JSON message, but it is base64 encoded, and you just need to decode it to get to the expected treasure inside.

Related

Coinbase Webhooks: is there a list of all data available?

I am looking into the webhook notifications and I am struggling to find documentation...
I would need to find the different payload for the "data" in the notification response...
the documentation only have one example: https://developers.coinbase.com/api/v2#show-a-notification
it is almost impossible to built an app if I need to try and see every type of notification by myself... (trial and error approach :( )
any extra resource? any help here?
thank you all
On this page, there is a link that says
See full list of notifications and corresponding payload information
But guess what, it links to the pages in your OP.
Even CB's newest documentation doesn't outline the payload until you run a sample to get the result displayed in the docs page. Here is a simple example, just click Try It to see the payload. It's not a bad thing until you need to see the payload of a signed request, then it's a PITA...
I've never used their webhooks to know how the payload differs but considering their docs you may need to run each notification to see what to expect and save the result to refer to later.

How can I search for messages (embeds) with a particular 'author' through DiscordSocketClient?

I'm in the process of building a new Discord bot (of course), and I've been working on the Twitter integration using Tweetinvi. I've got most of the Twitter streaming bits working normally (at least, as far as I can tell in my simplified testing), but I wanted to have the bot modify/delete posts in Discord if the Tweet is subsequently deleted. Tweetinvi has a TweetDeleted event that I can use to detect this as a part of my stream, but I'm having difficulty figuring out how to find the post in Discord.
What I'd like to do is "simply":
Search for posts (embeds) from the author (defined by the original Tweet)
Find the post with a matching .Url value in the embed
Replace that post with a message like "THIS TWEET WAS DELETED".
The problem I'm running into, however, is I can't seem to find a way to do "step 1" - search for and return any posts from the specified author. The only option I've found so far is the GetMessagesAsync method, but that doesn't seem to have a way to filter the results. Plus, with the "soft limit" of 100 messages, I worry that I could still not find the message I'm looking to delete.
I post the embeds using the DiscordSocketClient object in my class like this:
Me.A1FDiscordClient.GetGuild(Server.ID).GetTextChannel(PostingChannel).SendMessageAsync(MessageText.Trim, False, TweetBuilder.Build)
I had started working on something similar for the deletion/modification, but I think I'm simply spinning my wheels at this point:
Dim Messages = Me.A1FDiscordClient.GetGuild(Server.ID).GetTextChannel(PostingChannel).GetMessagesAsync(100)
I'm probably being dense and/or completely overlooking something, but I'm not even sure what to do with this once I have it. I was looking at using the .Select(Of TResult), but I think I've just gotten myself too twisted. I don't necessarily need a whole solution, but I could really use someone giving me a nudge in the right direction.
Discord does not provide an endpoints for Bots to search/filter on specific criteria. The only way to retrieve messages is to use the GetMessagesAsync() method
The limit for GetMessagesAsync() is technically Int32.MaxValue. The 100 that you see is simply the default. This is because Discord will return in chunks; 100 messages at a time. For example if you set the limit to 1000, you will get 10 chunks of 100.
Possible issues with retrieving a large number of messages? The main issue would be the length of time taken to retrieve the messages, which could block the gateway unless offload the process to its own task.
A possible solution would be to implement your own system for linking and storing twitter posts to discord posts. Could be as simple as a dictionary of Twitter post id and discord post id which would allow you to easily find the message id related to a given twitter post.

How to use novaexchange API

I am trying to get all their BTC market by accessing
Reply with quote Edit message Delete message #1
https://novaexchange.com/remote/v2/markets/BTC
It doesn't work.
I read their API documentation try to find samples on web and I can't find it
https://novaexchange.com/remote/faq/
The format is this
/remote/v2/markets/
Neither
https://novaexchange.com/remote/v2/markets/BTC
nor
https://novaexchange.com/remote/v2/markets/btc
works
So I wonder what's work. I look around on google and can't find a sample of URL that works.
I have play with this api in particular many times, the call that always works that is similar of the one you are trying is https://novaexchange.com/remote/v2/markets/ from there you have to filter the pairs for just getting BTC pairs.

Table blocked on YQL?

I'm trying to retrieve a user timeline from Twitter using YQL's community Twitter table. The full REST url is
https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20twitter.status.timeline.home%20WHERE%20oauth_consumer_key%20%3D%20'kt9wDTrDREjXzRhBMpw'%20AND%20oauth_consumer_secret%20%3D%20'zNnA76G3NhZSeaJdRv7munbyutlcqK8k0hazf6JrEo'%20AND%20oauth_token%20%3D%20'195tuy9661-yJFEsgA0VPCwg6gsNHtuy2y2Kq2LwTdKe4BRYa4j'%20AND%20oauth_token_secret%20%3D%20'myWfyDTtOHscMmJy6tuyU1XDyiZJiIIRkK7sIPvT2ngI'&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys
(keys have been mangled to protect the guilty)
The response I get is:
The current table
'twitter.status.timeline.user' has
been blocked. It exceeded the allotted
quotas of either time or instructions
As I seem to be doing the querying correctly, I'm at a bit of a loss as to why I should get this response, particularly since it works as it should through the YQL console. The only thing I can think of is that I need to authorize my query somehow with an API key, or oAuth credentials, but I haven't been able to find a comprehensible example of how to do this.
Can anyone possibly point me in the right direction on this? YQL's community tables seem to offer a marvelous way to do very complicated things with ease, so I'd hate to fall at the last hurdle so to speak.
According to the twitter docs the call to this API endpoint is supposed to return the last tweets from the authorized user, right? Not from any kind of user. Just checking that this is really what you want to achieve.
From: http://dev.twitter.com/doc/get/statuses/home_timeline
Returns the 20 most recent statuses,
including retweets if they exist,
posted by the authenticating user and
the user's they follow. This is the
same timeline seen by a user when they
login to twitter.com.
This is the definition of the datatable that you are using. I am a bit confused about the #id parameter in the example of that datatable because I don't see it being used anywhere.
www.datatables.org/twitter/twitter.status.timeline.home.xml
The error message you get sounds like an internal YQL error message and not like something that comes from Twitter, doesn't it?
Sorry for not being able to provide answer right now but maybe raising other related questions can help somebody else or you to figure it out. If I crack this later I will add to this again.

Google Reader API - get subscribers

Anyone know the http request in order to find the subscriber count for a subscription?
Something similar to http://www.google.com/reader/api/0/unread-count?all=true must exist for subscribers, no?
This is what Reader uses to fill in the data in the "show details" UI for a particular feeed:
http://www.google.com/reader/api/0/stream/details?s=feed/https://blog.stackoverflow.com/feed/&output=json&fetchTrends=false
Specifically, you'd want the "subscribers" property in the JSON output. The general format for the "s" parameter is feed/". Note that it requires authentication.
I wanted to do this same thing but from PUBLIC location so i hacked together an API for everyones use... it returns as JSON or JSONP and i dont save any history of feeds that are looked up... but i do have logging to be able to ban abusive ip