Getting started with Sony Audio Control API - sony-audio-control-api

Trying to use the new Sony Audio Control API with my STR-DN1080 (firmware M41.R.0377), but having a lot of trouble following the guide on https://developer.sony.com/develop/audio-control-api/. It's certainly pretty looking, but the Tutorials are not very helpful.
So based on that portal, it sounds like I need to discover the receiver's port via SSDP/UPNP. There's not much guidance on how to do this, so I used an Android app "UPNP Browser" and found 3 separate URLs. Within http://str.dn.1080.ip:52323/dmr.xml, I find the base URL:port and available services:
<av:X_ScalarWebAPI_DeviceInfo>
<av:X_ScalarWebAPI_Version>1.0</av:X_ScalarWebAPI_Version>
<av:X_ScalarWebAPI_BaseURL>http://str.dn.1080.ip:10000/sony</av:X_ScalarWebAPI_BaseURL>
<av:X_ScalarWebAPI_ServiceList>
<av:X_ScalarWebAPI_ServiceType>guide</av:X_ScalarWebAPI_ServiceType>
<av:X_ScalarWebAPI_ServiceType>system</av:X_ScalarWebAPI_ServiceType>
<av:X_ScalarWebAPI_ServiceType>audio</av:X_ScalarWebAPI_ServiceType>
<av:X_ScalarWebAPI_ServiceType>avContent</av:X_ScalarWebAPI_ServiceType>
</av:X_ScalarWebAPI_ServiceList>
</av:X_ScalarWebAPI_DeviceInfo>
Then, following the API reference for getSystemInformation (v1.4), I issue a GET to http://str.dn.1080.ip:10000/sony/system/getSystemInformation, but all I get back is {"error":[404,"Not Found"]}
I'm stumped now, and looking for help from Sony Developer Support. What am I missing? Is there something I need to enable on my receiver? Is there a hidden firmware that the Auto Updater won't apply?
Thanks!

For those searching on how to use the Sony API in Windows with curl, and to add onto the accepted answer, you'll need to replace the single quotes with double quotes and then escape the double quotes in the JSON:
curl -i -d "{\"method\": \"getSystemInformation\",\"id\": 1,\"params\":
[],\"version\": \"1.4\"}" http://str.dn.1080.ip:10000/sony/system
For postman, set type to POST, URL to: http://str.dn.1080.ip:10000/sony/system, and specify Body as raw/JSON, and paste the JSON:
{
"method":"getSystemInformation",
"id":1,
"params":[],
"version":"1.4"
}

The Sony Audio Control API is based on POST request.
So you have to use some program that can generate a POST request like curl to send requests
curl -i -d '{"method": "getSystemInformation","id": 1,"params": [],"version": "1.4"}' http://str.dn.1080.ip:10000/sony/system
You can also use programs like postman to send test requests if you want something with a GUI.

Related

How to do nginx request monitoring

I have gone through some tools like nagios, collectd but they din't find best as we need to monitor no_of_req/sec for each virtual host with all response status, with response time also.
I'm Using ELK Stack:
Separate access logs for each server block for better visibility or you can separate charts via URLs.
Then Use ELK stack:
Feed the logs to logstash via filebeat.
Create grok pattern for your log model.
Create charts via kibana and monitor in real time.
For realtime monitoring:
Try netdata, Its amazing. Please note its not a replacement for nagios or zabbix.
After some quick research, I found this: check_nginx_status.pl. I think defining something like:
define command {
command_name check-nginx
command_line $USER1$/check_nginx_status.pl -H $HOSTADDRESS$ -s $ARG1$ -u $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$
}
is probably just what you're looking for.
The -s flag ($ARG1$) would be the hostname of the virtual host
The -u flag ($ARG2$) would be the specific url (/something/status)
And then the rest of the args would be used if you needed to add any additional flags.
Hope this helps!

How to receive & process data when I subscribe to youtube api v3 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

Basic HTTP Authentication with python 3.2 (urllib.request)

This is my first post with this account, and Ive been struggling for the last week to get this to work, so I hope someone can help me get this working.
Im trying to pull some data from https://api.connect2field.com/ but its rejecting all of my authentication attempts from python (not from a browser though).
The code Im using
import urllib.request as url
import urllib.error as urlerror
urlp = 'https://api.connect2field.com/api/Login.aspx'
# Create an OpenerDirector with support for Basic HTTP Authentication...
auth_handler = url.HTTPBasicAuthHandler()
auth_handler.add_password(realm='Connect2Field API',
uri=urlp,
user='*****',
passwd='*****')
opener = url.build_opener(auth_handler)
# ...and install it globally so it can be used with urlopen.
url.install_opener(opener)
try:
f = url.urlopen(urlp)
print (f.read())
except urlerror.HTTPError as e:
if hasattr(e, 'code'):
if e.code != 401:
print ('We got another error')
print (e.code)
else:
print (e.headers)
Im pretty sure the code is doing everything right, which makes me think that maybe theres another authentication step that ASP.net requires. Does anybody have any experience with ASP.Net's authentication protocol?
Im gonna be checking this post throughout the day, so I can post more info if required.
Edit: Ive also tried running my script against a basic http auth server running at home, and it authenticates, so Im pretty sure the request is set up properly.
It appears that IIS is set up to do basic authentication, ASP.NET will be most probably be configured to use windows authentication.
As you have said that authentication works via browser, so the best bet for you is to use tool such as fiddler to capture request/response when connecting via browser and also when connecting via your code. Compare them to troubleshoot the issue.
For example, I remember a case where the web site first requested authentication credentials and then re-directed to different url which prompted for different credentials.

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

cURL and ActiveMQ

I need an example on how to read/write to an ActiveMQ queue over HTTP in C or C++ using cURL (or something else, I'm open to anything at this point).
I have working code in C#, but it doesn't help.
Any help is appreciated,
Thank you.
First I assume:
You are running activemq 5.5.0
You are using the default activemq configuration that enables the web-console
Test it by pointing a browser to http://localhost:8161/admin
By cURL you mean libcurl and a command line example is sufficient
Example:
Create a queue named test, set the body to hello world.
Note: [clientId] this a unique string to identify your subscribe otherwise a new consumer will be created for each request see REST
$ curl -d 'body="Hello World"' "http://localhost:8161/demo/message/test?type=queue&clientId=consumerA"
Pop the message of the queue
$ curl -X delete "http://localhost:8161/demo/message/test?type=queue&clientId=consumerA"
You should see "Hello World"
Finally unsubscribe from the queue
$ curl -d 'action=unsubscribe' "http://localhost:8161/demo/message/test?type=queue&clientId=consumerA"
You should be able to monitor all of the above operations from the admin interface
Until version 5.8, REST API was part of the Web Samples and was mapped
to http://localhost:8161/demo/message url. From 5.8 onwards, the API
is available by default at http://localhost:8161/api/message url
http://activemq.apache.org/rest.html

Resources