YouTube API. Check for user was subscribed - api

What the best way to determine when authorized user was subscribed to YouTube channel by channel's id through YouTube Data API? I assuming it is possible somehow by "Subscriptions.list" API method. But how exactly?

If you know the channelId of the channel you want to check the user is subscribed to, you can perform an HTTP GET request on the subscriptions/list endpoint with the parameters part set to id and mine set to true:
HTTP GET https://www.googleapis.com/youtube/v3/subscriptions?part=id&mine=true&key={YOUR_API_KEY}
You could also pass in snippet for part to get information about each channel the user is subscribed to. With this approach, you would have to iterate through every channel that authenticated user is subscribed to, and check if your channel exists in that list.
You could also send an authenticated POST request to the subscriptions/insert endpoint with the channelId of the channel you want to subscribe to with the part param snippet, and if the user is already subscribed to that channel, the request will return a 400 error with the message subscriptionDuplicate.
HTTP POST https://www.googleapis.com/youtube/v3/subscriptions?part=snippet&key={YOUR_API_KEY}

Related

Viber REST API, how to find Unique Viber user id?

Resource URL https://chatapi.viber.com/pa/send_message
General send message parameters
I am trying to send message to viber from Postman. I don't know how to find Unique Viber user id, that parameter is required.
I am getting this error:
{"status":999,"status_message":"Bad receiver ID","message_token":5126721184521938239}
Danny Dainton mentioned the docs on how you can get data including unique ID about your own account not about somebody else!
You'll receive callbacks containing user unique ID to your webhook if a user subscribes to your public account, and ONLY THEN you'll be able to send message to that user.
As per viber docs:
The send_message API allows accounts to send messages to Viber users who subscribe to the account. Sending a message to a user will be possible only after the user has subscribed to the Public Account by pressing the subscribe button or by sending a message, or by sending a message to a bot (see subscribed callback for additional information).
and VERY IMPORTANT
Before an account can send messages to a user, the user will need to
subscribe to the account. Subscribing can take place in one of two
ways:
User sends message to the account (both Public Accounts and bots)
when a user sends its first message to a account the user will be
automatically subscribed to the account. Sending the first message
will not trigger a subscribe callback, only a message callback (see
receive message from user section). Subscribed event is sent to the
Public Account (Public Accounts only)
user clicks a subscribe button
which triggers the subscribe callback as described below.
Simple, just call the Get Account Info API, whose resource URL is https://chatapi.viber.com/pa/get_account_info
You will find the a list of all subscribers in the response along with their user IDs. Please note that these user IDs are unique per user per public account.
Correction: It seems like the Get Account Info API does not return all subscribers, it just returned for me my user ID (the admin of the public account). Based on this, there is no way to get the user IDs of your subscribers other than from the callbacks for new subscribers, messages, ...etc.
Normally you should collect Viber IDs from all callbacks and store in DB for future use. But if you missed that step you can collect Viber IDs of online subscribed users by periodic call to get_online endpoint and then use get_user_details endpoint to get more info about unknown ones.

Can a slackbot pull messages from a private channel and post in another slack channel?

I am wondering if a slack bot can pull messages that are tagged with a certain string of characters from a private channel and then post that "tagged" message in another channel (private or public). All within the same slack group.
Yes, a Slack bot can do that. But he needs to be invited to a channel (public and private) to be able to monitor it. He then receives all messages in that channel and can react to it in any way you want. Bots can only use a subset of all Slack API methods, but yes they can post a copy of a message to another channel based on keywords.
See the Slack documentation on bots for more information.
Also try setting up a webhook from that slack channel, I've had success with that

Send message to th all of bots users (telegram api)

how to send Send message to the all of bots users?
There is no way to sned message to all ?
what is the method name ?
From Official API FAQ:
How can I message all of my bot's subscribers at once?
Unfortunately, at this moment we don't have methods for sending bulk messages, e.g. notifications. We may add something along these lines in the future. (...)
Obviously, if you store users chat_id, you can send individual message to all users (I use this method).
Navid wants to send message to all subscribers via bot.
If subscribers are more than 100 persons bot will very slow to sending all messages and may doesn't send messages to all.
Navid's question was how we can send message without this problem?
you can send with curl_multi_exec
Currently, a developer would need to implement a special broadcasting function that would send the message to each active user at the time adding a small delay to avoid hitting the rate limit of 30 messages per second (see https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once). This would mean that a very popular bot with say 10K active users cannot give timely notification as the last user would get the message about 5 minutes after the first user.
Here is a feature request to ask to add a method in the Bot API to broadcast a message to all its active users at once. You can upvote this feature request. https://bugs.telegram.org/c/8463

MailChimp/Mandrill webhook for message created/scheduled

Is it possible to get MailChimp or Mandrill to notify a webhook URL whenever a message is either created for a list, or scheduled to be sent, along with the list and message IDs?
I have a client that wants to intercept messages from his campaign, add special data from his server, then send the resulting template through his connected Mandrill account. I'm trying to figure out how to implement the first step in this process.
Although I know this is old someone may stumble into this thread, have you checked out the webhook information?
http://help.mandrill.com/entries/58303976-Message-Event-Webhook-format
It has an easy way to implement it inside the account. You just setup a URL to intercept and parse the incoming data. I recommend first saving the data then using a scheduled task to parse the job separately so you don't lose data (although mandrill will try 100x).
If the unique id is not enough for you with your events, and you are concerned about specific campaigns you can tag the emails upon send and they will have the tagged information with the incoming event.

How can I send message to specific chatID?

I have chatId and want send messages while execute some tasks from java code. I found this explain on telegram "Bots can't initiate conversations with users. A user must either add them to a group or send them a message first. People can use telegram.me/ links or username search to find your bot." But my task works good when I use https request directly from browser. My bot perfectly answer for requests but how I can do this without user request?
I can not truly understand your case!
Anyway, your bot can send a message to a chat ID Only if the user witch blongs to the specified chat ID added your bot (send start to a bot).
and if it happened then send your message with
/sendMessage