How to receive & process data when I subscribe to youtube api v3 push notification? - push-notification

According to this https://developers.google.com/youtube/v3/guides/push_notifications
I can subscribe to a youtube channel & receive push notification for any new video.
My callback server is a php script which interprets POST/GET data:
<?php
if (isset($_GET['hub_challenge'])) {
print $_GET['hub_challenge'];
}
else {
$xml=file_get_contents("php://input");
file_put_contents('endpoint.txt',$xml);
}
?>
But $xml is empty. In the docs it says:
The YouTube Data API (v3) supports push notifications via
PubSubHubbub, a server-to-server publish/subscribe protocol for
Web-accessible resources. Notifications are pushed out to subscribers
via HTTP webhooks, which is much more efficient than polling-based
solutions.
But it does not specify how does it send the data....whether in POST body or in somewhere else.
So How do I get the atom feed in my script?
EDIT: I should probably ask a new question for this...but anyway....I tried this channel (https://www.youtube.com/channel/UCATp8LNTjzjNlLxdArp0Myg); but when I try to subscribe it says "restricted topic" (I did not provide token as it is a public channel). Same for any other channel ID. Is something wrong with my callback server? I also tried runscope url as a callback server for testing. But it did not help.

Others are having similar problems. Here is the issue log:
https://code.google.com/p/gdata-issues/issues/detail?id=7138
and related StackOverflow question:
Youtube API - Subscribing to Push Notifications
Unfortunately, no one seem to provide a solution although you can follow the issue and track any progress.

Yes it send data on the POST body . If you are using Express Nodejs add app.use(bodyParser.xml()) middleware to parse xml data

Related

Webhook limitations in linkedin API (webhook is not receiving updates)

LinkedIN has recently released support for webhooks and we are successful in creating a webhook url. We are able to authorise a user administrator of a company to our app and get permissions to write and read from the REST API.
However we are not receiving any webhook updates from the app for that company. And there is no documentation on how to subscribe to a particular company like in other social-media API:s witch we have vast experience from (fb,IG,Twitter).
The documentation on LinkedIn is very limited on the subject. And we are not sure what we can expect from the webhook requests from linkedIn. What is the reason we are not getting Webhooks for that company?
We dont even get webhook calls for the organisation owning the app.
Any help appreciated.
https://learn.microsoft.com/en-us/linkedin/shared/api-guide/webhook-validation?context=linkedin/context
I figure it out I need to add header json to output for validation.
Here is my code in php
if (isset($_REQUEST['challengeCode'])) {
header('Content-Type: application/json');
echo json_encode([
'challengeCode' => $_REQUEST['challengeCode'],
'challengeResponse' => hash_hmac('sha256', $_REQUEST['challengeCode'], 'client secret'),
]);
exit;
}
and for webhook subscription
$api->setApiHeaders([
'X-Restli-Protocol-Version' => '2.0.0',
]);
$developerUrn = urlencode("urn:li:developerApplication:developerid");
$personUrn = urlencode("urn:li:person:personid");
$orgUrn = urlencode(""urn:li:organization:pageid");
$endpoint = "(developerApplication:$developerUrn,user:$personUrn,entity:$orgUrn,eventType:ORGANIZATION_SOCIAL_ACTION_NOTIFICATIONS)";
$api->api("eventSubscriptions/$endpoint", ['webhook' => "WEBHOOK_URL"], 'PUT');
Webhooks are a closed beta feature at this time:
Who can use this: Any developer using a webhooks API (currently available only for social action notifications on company posts to beta partners)
Source: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/recent-changes

Telegram `setTyping` API call

I'm trying to set my bot's typing status by sending the following POST request (based on the API docs):
https://api.telegram.org/bot{{botToken}}/setTyping
{
peer: {{chat_id}},
typing: true,
action: 'sendMessageTypingAction'
}
I've tried a few variations of it, such as changing the url to be /messages.setTyping and sending the action as {"_":"sendMessageTypingAction"} as seen here, but all I get is:
{
"ok": false,
"error_code": 404,
"description": "Not Found: method not found"
}
Anyone know what I'm doing wrong?
Thanks to #tashakori for pointing me in the right direction towards the Bot API. For posterity, what I needed to do was:
https://api.telegram.org/bot{{botToken}}/sendChatAction
{
chat_id: {{chatId}},
action: 'typing'
}
The link you have mentioned above belongs to Telegram Core APIs which is used for handling ordinary accounts of Telegram. These so-called Core APIs are not related to Telegram Bot APIs.
The only API that is somehow similar to SetTyping for bots is AnswerCallbackQuery, which can be used only when responding to the user's interaction with inline keyboards. (you can send a text to the user, saying that there is a process running in the background and whenever the user's answer is ready, you can send it using APIs like sendMessage)

Can I add elements to the aps payload sent by the Bluemix IBM Push Notifications service?

I'm successfully using Bluemix Push to send notifications via the REST interface to an iOS app with a simple string alert message. That works fine.
Now I would like to send a more complex message where alert is a dictionary and has a sibling "category" element per The Remote Notification Payload.
Is this possible with Bluemix Push? Whenever I try to deviate from the basic structure, I get "Bad Request - Invalid JSON".
After much head-scratching, I finally picked up a hint from https://www.ng.bluemix.net/docs/services/mobilepush/t_advanced_notifications.html#t_push_badge_sound_payload and figured out that since the category field is unique to APNS, what I needed to send is
"settings" : {
"apns" : {
"category" : "myCategory"
}
#DSchultz_mo I was having issues to find the documentation but I finally found it, so if you go to https://mobile.ng.bluemix.net/imfpushrestapidocs/#/ you can use swagger to register your device and send notification and the magic button is in model there is more details for sendMessageBody

Invalid tag for push notifications in Windows Azure

I am building a Windows Phone 8.1 application and want to add push notifications from Windows Azure. I am creating the channel by using CreatePushNotificationChannelForApplicationAsync, after which I take the resulting URI and store it in the Azure database. When trying to send a push notification by using push.wns.sendToastText01, I get the following error in the Azure logs:
Error in script '/table/Message.insert.js'. Error: 400 - An invalid tag 'https://db3.notify.windows.com/?token=AwYAAAC3tTi3W5ItZ0hWdZ3FLmELt%2flHcwpsM...' was supplied. Valid tag characters are alphanumeric, _, #, -, ., : and #.
I noticed that the channel URI contains the '%' which does not appear among the valid characters, yet that is the URI that gets generated in the client application. Am I using a wrong method for sending push notifications or is there something else I am missing?
Edit: I am using Node.js for backend in Azure.
request.execute({
success: function() {
push.wns.sendToastText01(channelUri, {
text1: "Google Plus Friend Tracker",
text2: item.content,
param: '/ChatPage.xaml?friendGoogleId=' + item.author_id
})
}
});
Looking at the wns object documentation, the first parameter would be the tags that you are sending to. Since you're providing a channel in the code above, you are getting the error specified.
The backend does not need to provide the channel URI, as this was associated with the Notification Hub via the client-side registration action. If you are broadcasting the message, you would just provide null as the tag value. Otherwise, you can use the tags that were specified when you registered the channel URI.
For more about the process, see the "Get started with push" tutorial. There is also an example of using a tag (user ID) in the "Send push notifications to authenticated users" tutorial. For more on tags in general, the Notification Hubs breaking news tutorial is also good.

What is the URL to make a Google Voice call using the direct access number?

I am trying to write a Google Voice app and was wondering if anyone knew the url and post parameters to make a call using the direct access number instead of the ring-back.
For example, to call 1-800-555-0111, enter
https://voice.google.com/u/0/calls?a=nc,%2B18005550111
I did not test it, but check this api: http://code.google.com/p/google-voice-java/
Specially, the voice.java at line 711, which is the method:
public String call(String originNumber, String destinationNumber,
String phoneType) throws IOException {
In line 737 they use:
URL callURL = new URL("https://www.google.com/voice/call/connect/");
and the full comments for the methods say:
// POST /voice/call/connect/
// outgoingNumber=[number to call]
// &forwardingNumber=[forwarding number]
// &subscriberNumber=undefined
// &phoneType=[phone type from google]
// &remember=0
// &_rnr_se=[pull from page]
I hope this helps.
I don't think there is an official API, but this site seems to have made some progress with the URLs you are after: http://posttopic.com/topic/google-voice-add-on-development , and there is an unofficial API here: http://sourceforge.net/projects/gvoicedotnet/
Google Voice does not expose an API to the service however, there are many 3rd party libraries that mock an API by screen scraping via Google Voice's HTML website. I better solution though is to use the google voice service via SIP. Search for "google voice sip asterisk" and you will find out about this. Basically if you install this software called asterisk it can make calls via google voice.
See this article for a start:
http://eggie5.com/10-installing-asterisk-on-osx

Resources