Unable to Edit/Create playlists in "playlists" container in Sonos version 5.4 (latest update) - sonos

When I updated to version 5.4 I no longer have the option to create a playlist in the "playlists" container, nor to add a track to a playlist already existing in it. In version 5.3 it was working well. I also checked other Music Services on Sonos, same problem. Did anything change in the specifications for User Content Playlists that is not specified in the documentation for Playlist Editing?
This is how I'm adding my User Content container:
$result->mediaCollection[] = array('id'=>'playlists', 'title'=>'My Playlists', 'itemType'=>'favorites', 'containsFavorite'=>true, 'displayType'=>'genreList', 'readOnly'=>false, 'userContent'=>true, 'renameable'=>true, 'albumArtURI'=>PATH.'/img.png');
Edit:
I am using the Android controller (version 5.4, build 29590261) and I am testing on a Play:1 (version 5.4, build 29591030).
I am able to add a song/playlist to an already existing playlist or to a new playlist (by long press on a song to get to the extended metadata, and then "Add Track to 'Service Name' Playlist"), but what I can't figure out how to do is: deleting a playlist, renaming a playlist, and editing songs in a playlist (reorder, delete songs). I don't have a screenshot for version 5.3 but there was an button in the top right corner (three vertical dots) of the playlists container from which one can edit playlists or create new ones (check the screenshots below, from version 5.4). Am I missing something?
Edit 2:
I figured out what is causing the issue. I am using the .wsdl for beta in order to be able to implement Custom Item Display (This is not beta anymore, as I understood from the Adding New SMAPI Features page). When I revert to the normal Sonos.wsdl file from the Sonos Documentation, the info and options button appears again. How can I use Custom Item Display while keeping the info and options button there and all functionalities of playlist editing unchanged?
Note: the Sonos(beta).wsdl was here but it's not available anymore.
Edit 3:
I downloaded the Sonos.wsdl from the Sonos documentation, but I still can't see the button. In order to reproduce the issue, please check the following PHP implementation and Presentation Map XML code:
PHP implementation:
define('BASE_PATH', rtrim("http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']), '/'));
class SonosAPI
{
public function getMetadata($args)
{
$result = new StdClass();
$result->index = $args->index;
switch($args->id) {
case 'root':
$result->mediaCollection[] = array('id'=>'playlists', 'title'=>'My Playlists', 'itemType'=>'favorites', 'displayType'=>'genreList', 'readOnly'=>false, 'userContent'=>true, 'renameable'=>true, 'albumArtURI'=>BASE_PATH.'/image.png');
$result->count = $result->total = 1;
break;
case 'playlists':
$result->mediaCollection[] = array('id'=>'123', 'title'=>'Title', 'itemType'=>'playlist', 'displayType'=>'genreList', 'canPlay'=>true, 'readOnly'=>false, 'userContent'=>false, 'renameable'=>true, 'albumArtURI'=>BASE_PATH.'/image.png');
$result->count = $result->total = 1;
break;
}
return array('getMetadataResult' => $result);
}
}
$server = new SoapServer("Sonos.wsdl", array('cache_wsdl' => 0)); // disable cache in development
$server->setClass('SonosAPI');
try {
$server->handle();
} catch (Exception $e) {
Log("[ERROR] ".$e->getMessage());
}
?>
Presentation Map file:
<?xml version="1.0" encoding="utf-8" ?>
<Presentation>
<PresentationMap type="DisplayType">
<DisplayType id="genreGrid">
<DisplayMode>GRID</DisplayMode>
</DisplayType>
<DisplayType id="genreList">
<DisplayMode>LIST</DisplayMode>
</DisplayType>
<DisplayType id="genreHero">
<DisplayMode>HERO</DisplayMode>
</DisplayType>
<DisplayType id="genreEditorial">
<DisplayMode>EDITORIAL</DisplayMode>
</DisplayType>
<DisplayType id="twoLine">
<Lines>
<Line token="title"/>
<Line token="summary"/>
</Lines>
</DisplayType>
</PresentationMap>
</Presentation>
XML response to getMetadata of root (which contains the playlists container):
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns1="http://www.sonos.com/Services/1.1" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<ns1:getMetadataResponse>
<ns1:getMetadataResult>
<ns1:index>0</ns1:index>
<ns1:count>4</ns1:count>
<ns1:total>4</ns1:total>
<ns1:mediaCollection>
<ns1:id>rootlang:ar</ns1:id>
<ns1:itemType>collection</ns1:itemType>
<ns1:displayType>genreGrid</ns1:displayType>
<ns1:title>Arabic</ns1:title>
<ns1:albumArtURI>{SOME LINK}</ns1:albumArtURI>
</ns1:mediaCollection>
<ns1:mediaCollection>
<ns1:id>rootlang:en</ns1:id>
<ns1:itemType>collection</ns1:itemType>
<ns1:displayType>genreGrid</ns1:displayType>
<ns1:title>International</ns1:title>
<ns1:albumArtURI>{SOME LINK}</ns1:albumArtURI>
</ns1:mediaCollection>
<ns1:mediaCollection>
<ns1:id>rootlang:default</ns1:id>
<ns1:itemType>collection</ns1:itemType>
<ns1:displayType>genreGrid</ns1:displayType>
<ns1:title>Arabic + International</ns1:title>
<ns1:albumArtURI>{SOME LINK}</ns1:albumArtURI>
</ns1:mediaCollection>
<ns1:mediaCollection renameable="true" readOnly="false" userContent="true">
<ns1:id>playlists</ns1:id>
<ns1:itemType>favorites</ns1:itemType>
<ns1:displayType>genreList</ns1:displayType>
<ns1:title>My Playlists</ns1:title>
<ns1:albumArtURI>{SOME LINK}</ns1:albumArtURI>
</ns1:mediaCollection>
</ns1:getMetadataResult>
</ns1:getMetadataResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
XML response to getMetadata of playlists:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns1="http://www.sonos.com/Services/1.1" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<ns1:getMetadataResponse>
<ns1:getMetadataResult>
<ns1:index>0</ns1:index>
<ns1:count>1</ns1:count>
<ns1:total>1</ns1:total>
<ns1:mediaCollection renameable="true" readOnly="false" userContent="false">
<ns1:id>playlist:19663408</ns1:id>
<ns1:itemType>playlist</ns1:itemType>
<ns1:displayType>genreList</ns1:displayType>
<ns1:title>Test Playlist</ns1:title>
<ns1:canPlay>true</ns1:canPlay>
<ns1:albumArtURI>{SOME LINK}</ns1:albumArtURI>
</ns1:mediaCollection>
</ns1:getMetadataResult>
</ns1:getMetadataResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Custom Display Types were made available in the most recent production software update. The beta wsdl that you were using is for v5.4 which is now the current production build. Make sure that you are using the production version of the wsdl and you will have info & options and also have access to Custom Display Types (provided they are properly enabled in your service).
However I have confirmed that we do have a bug when using Display Types with playlist containers when playlist editing is enabled. The work around is to removed the displayType node from your root playlist and child playlist containers (all other containers that use displayType do not need to be changed). This work around has been tested and works. We have opened an issue to track this internally.

Related

How do I invoke a MobileFirst Platform Adapter using PUT?

This is similar to the question asked here, but that question was not exactly answered to what the problem is.
Customer.xml
<?xml version="1.0" encoding="UTF-8"?>
<wl:adapter name="Customer"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wl="http://www.ibm.com/mfp/integration"
xmlns:http="http://www.ibm.com/mfp/integration/http">
<displayName>Customer</displayName>
<description>Customer</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>https</protocol>
<domain>kenatibm.cloudant.com</domain>
<port>443</port>
</connectionPolicy>
</connectivity>
<procedure name="addCustomer"> </procedure>
</wl:adapter>
Customer-impl.js
function addCustomer(param1) {
var input = {
method : 'PUT',
returnedContentType : 'json',
path : 'userInputRequired',
body : {
contentType: 'application/json',
content : param1
}
};
return WL.Server.invokeHttp(input);
}
The issue is that even though I have defined the method as a PUT, when testing using File Run As | Call MobileFirst Adapter the user interface only displays a GET method, there is no option for PUT.
So is the answer that the GET will actually do a PUT or is this a bug or is there a configuration parameter that I am missing?
I think you are confusing how you invoke/test the adapter, with what verb it uses on the back-end system it is calling. You are testing/invoking it using GET, but the adapter is then calling your backend system - http://kenatibm.cloudant.com/backendsystem - using PUT.
This is broadly the same explanation as Dave gave in your previous question.
In short, the answer is that the GET will actually do a PUT.
Parameters are passed to the adapter in a GET request and then the adapter constructs a PUT request to perform the actual procedure. In your code, you can see how the 'param1' is passed by the wizard to the function and then it is set to as the 'content' of the PUT request. It's definitely a little confusing.

Titanium - App does show from notification only once

My app sometimes displays multiple android notifications. When someone clicks on them, my app should show up with the content of the notifications.
I've managed to do it, but it only works for the first notification the user clicks on. If I leave the application after this (for example with the homebutton) and click then on the next notification, nothing happens.
I've created an example application to show you what I have at the moment. You can find it here: https://github.com/VanCoding/TitaniumNotificationTest
What am I doing wrong? How do I achieve what I want?
app.js
if(!Ti.App.Properties.getBool("displayedNotifications")){
var notifications = ["Apple","Orange","Banana"];
for(var i = 0; i < notifications.length; i++){
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_MAIN,
packageName:"com.company.notificationtest",
className:"com.company.notificationtest.NotificationtestActivity",
flags:Ti.Android.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Ti.Android.FLAG_ACTIVITY_SINGLE_TOP
});
intent.addCategory(Ti.Android.CATEGORY_LAUNCHER);
intent.putExtra("name",notifications[i]);
Titanium.Android.NotificationManager.notify(i, Titanium.Android.createNotification({
contentTitle: notifications[i],
contentText : notifications[i],
contentIntent: Ti.Android.createPendingIntent({
intent:intent,
type : Ti.Android.PENDING_INTENT_FOR_ACTIVITY,
flags : Ti.Android.FLAG_ACTIVITY_NO_HISTORY
}),
flags : Titanium.Android.ACTION_DEFAULT | Titanium.Android.FLAG_AUTO_CANCEL | Titanium.Android.FLAG_SHOW_LIGHTS
}));
}
Ti.App.Properties.setBool("displayedNotifications",true);
}
tiapp.xml
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
<id>com.company.notificationtest</id>
<name>NotificationTest</name>
<version>1.0</version>
<publisher>not specified</publisher>
<url></url>
<description>not specified</description>
<copyright>not specified</copyright>
<icon>appicon.png</icon>
<fullscreen>false</fullscreen>
<navbar-hidden>false</navbar-hidden>
<analytics>true</analytics>
<guid>91e86075-373b-44e0-9416-66183390e8af</guid>
<property name="ti.ui.defaultunit" type="string">dp</property>
<android xmlns:android="http://schemas.android.com/apk/res/android">
</android>
<modules>
</modules>
<deployment-targets>
<target device="android">true</target>
</deployment-targets>
<sdk-version>3.2.3.GA</sdk-version>
</ti:app>
Changing:
contentIntent: Ti.Android.createPendingIntent({
intent:intent,
type : Ti.Android.PENDING_INTENT_FOR_ACTIVITY,
flags : Ti.Android.FLAG_ACTIVITY_NO_HISTORY
}),
to:
contentIntent: Ti.Android.createPendingIntent({
intent:intent,
type : Ti.Android.PENDING_INTENT_FOR_ACTIVITY
}),
fixes it for me. Tested using 3.3.0.GA.

Perform authentication to Polarion webservice with Savon

I am attempting to follow the discussion here using Ruby and Savon. I am able to retrieve a session ID, but whenever I perform a request from the clients that require authentication (tracker), I receive an Authorization Failed error.
require 'Savon'
tracker_url = 'http://myserver/polarion/ws/services/TrackerWebService?wsdl'
session_url = 'http://myserver/polarion/ws/services/SessionWebService?wsdl'
# todo handle bad login credentials gracefully
session_client = Savon.client(wsdl: session_url)
response = session_client.call(:log_in, message: {user_name: 'lsimons', password: 'mypassword'})
session_id = response.header[:session_id]
puts "Session ID: #{session_id}"
tracker_client = Savon.client(wsdl: tracker_url, soap_header: {"session" => session_id}, headers: {"sessionID" => session_id})
puts "Requesting Workitem"
begin
tracker_client.call(:get_work_item_by_id, message: {project_id: 'myProject', workitem_id: 'myWorkitem'})
rescue
puts "Client call failed"
end
This code creates the following SOAP request for the tracker_client:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://ws.polarion.com/TrackerWebService-impl" xmlns:ins1="http://ws.polarion.com/types" xmlns:ins2="http://ws.polarion.com/TrackerWebService-types" xmlns:ins3="http://ws.polarion.com/ProjectWebService-types" xmlns:tns1="http://ws.polarion.com/TrackerWebService" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header>
<session>2164640482421325916</session>
</env:Header>
<env:Body>
<tns1:getWorkItemById>
<ins0:projectId>myProject</ins0:projectId>
<ins0:workitemId>myWorkitem</ins0:workitemId>
</tns1:getWorkItemById>
</env:Body>
</env:Envelope>
However, in the forum discussion, the sessionID element occurs before the header. I didn't think this was possible with standard SOAP? Is there a way to achieve this with Savon or am I misinterpreting the forum discussion?
I faced the same problem following the same thread. This is how I made it work (by replicating the response headers of the log_in request):
tracker_client = Savon.client(
wsdl: tracker_url,
soap_header: {
"ns1:sessionID" => session_id,
:attributes! => {
"ns1:sessionID" => {
"env:actor" => "http://schemas.xmlsoap.org/soap/actor/next",
"env:mustUnderstand" => "0",
"xmlns:ns1" => "http://ws.polarion.com/session"
}
}
}
)
Old question but thought I can add some info to hopefully help somebody.
I am using lolsoap to talk to polarion. In the above resulting document, the sessionID element is wiped off any namespaces and attributes. Also the assessment is right that actor and mustUnderstand attributes seem irrelevant.
To add header properly though with all fluff, one needs to get the Nokogiri::XML::Node and dup it, then add it to the header of the doc. This is a bug in nokogiri/libxml2 that adding child elements can often break namespaces unless Node is cloned before adding [1].
In lolsoap it is done something like:
auth_header = login_response.nokogiri_doc.xpath("//*[local-name()='sessionID']")[0].dup
other_request.header.__node__ << auth_header
Please note the dup operation. header.__node__ is just the header Nokogiri::XML::Element of a random SOAP request.
The dup operation makes adding desired element into another one with all necessary namespaces and attributes properly defined.
I don't know if savon allows one to directly touch request XML but I guess it does. Thus HTH
[1] https://github.com/sparklemotion/nokogiri/issues/1200

Dump Symfony2 assets to Amazon S3

I'd like to dump my assets to my s3 bucket in production, after deploying with capifony in Symfony 2. I've found some solution, but don't really find out the best to use.
It's possible the dump the assets with Zend_Service_Amazon_S3 but I think it's a bit overkill to import the Zend framework only for this. - http://permalink.gmane.org/gmane.comp.php.symfony.symfony2/54
I've also found this: https://github.com/symfony/symfony/pull/108, where I can tell AsseticBundle the bucket name, but I didn't found where to provide the key and secret for my aws account.
Can you point out a better solution, or give me some detailed information on the above mentioned ones.
So what I've done and it is working.
Add at composer.json and install it
"aws/aws-sdk-php": "2.6.16",
Create a service:
<?php
namespace My\AcmeBundle\Amazon;
use Aws\Common\Aws;
class StreamWrapperS3 {
protected $s3;
public function __construct($key, $secret, $region) {
$aws = array(
'key' => $key,
'secret' => $secret,
'region' => $region
);
$this->s3 = Aws::factory($aws)->get('s3');
}
public function registerStreamWrapper() {
$this->s3->registerStreamWrapper();
}
}
Declare the service atconfig.yml or including it as a file
services:
my_amazon_s3:
class: My\AcmeBundle\Amazon\StreamWrapperS3
arguments: [%aws_key%, %aws_secret_key%, %aws_region%]
Add the parameters at parameters.yml
Override boot() method at AppKernel.php:
public function boot() {
parent::boot();
$s3client = $this->container->get('my_amazon_s3');;
$s3client->registerStreamWrapper();
}
At config_prod.yml add:
framework:
templating:
assets_base_url: https://sa-east-1.amazonaws.com/your-bucket-name
assetic:
write_to: 's3://your-bucket-name'
Finally add the filter with your assets to rewrite correctly your paths:
{% stylesheets filter='cssrewrite'
'bundles/...' %}
<link rel="stylesheet" href="{{ asset_url }}" /> {# asset just to be sure that url will be right #}
{% endstylesheets %}
So each time that you've changed something need to run:
php app/console cache:clear --env=prod
php app/console assets:install --env=prod
php app/console assetic:dump --env=prod
A very important detail that took almost 2 days of my time, you need to update CORS of Amazon S3 to access some files as fonts add inside twitter bootstrap css for example. My CORS permissions are like this:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
Actually you don't really need and probably even shouldn't, put your key in the application code. In Amazon S3 you can specify access by sender, in this case you're production server address.
Take a look at the provided post link:
https://forums.aws.amazon.com/thread.jspa?messageID=236066
This would allow you to freely write from that server to your bucket. Remember also to deny access from every other ip.
I've also found this: https://github.com/symfony/symfony/pull/108,
where I can tell AsseticBundle the bucket name, but I didn't found
where to provide the key and secret for my aws account.
This should work - just use the following form when specifying the S3 bucket URL:
# config_prod.yml
assetic:
write_to: s3://{key}:{secret}#{bucket}/

Check if twitter username exists

Is there a way to check if a twitter username exists?
Without being authenticated with OAuth or the twitter basic authentication?
UPDATE 2021: This API is not available.
As of right now, you're better off using the API the signup form uses to check username availability in realtime. Requests are of the format:
https://twitter.com/users/username_available?username=whatever
And give you a JSON response with a valid key giving you a true if the username can be registered:
{"valid":false,"reason":"taken","msg":"Username has already been taken","desc":"That username has been taken. Please choose another."}
{"valid":true,"reason":"available","msg":"Available!","desc":"Available!"}
{"valid":false,"reason":"is_banned_word","msg":"Username is unavailable","desc":"The username \"root\" is unavailable. Sorry!"}
The reason this is better than checking for 404 responses is that sometimes words are reserved (like 'root' above), or a username is actually taken but for some reason the account is gone from the Twitter front end.
UPDATE
The Twitter REST API v1 is no longer active.
So use
https://api.twitter.com/1.1/users/show.json?screen_name=username
You can also use the API with username :
http://api.twitter.com/1/users/show.xml?screen_name=tarnfeld
Will give you :
<?xml version="1.0" encoding="UTF-8"?>
<user>
...................
<screen_name>tarnfeld</screen_name>
<location>Portsmouth, UK</location>
.................
</status>
</user>
Or if not exist :
<?xml version="1.0" encoding="UTF-8"?>
<hash>
<request>/1/users/show.xml?screen_name=tarnfeldezf</request>
<error>Not found</error>
</hash>
As API v1 is no longer available, here is another way to check if a twitter account exists. The page headers of a non existing account contain 404 (page not found).
function twitterAccountExists($username){
$headers = get_headers("https://twitter.com/".$username);
if(strpos($headers[0], '404') !== false ) {
return false;
} else {
return true;
}
}
Here is how it works on PHP :
$user_infos = 'http://api.twitter.com/1/users/show.xml?screen_name='.$username;
if (!#fopen($user_infos, 'r'))
{
return false;
}
return true;
This worked for me, close to what sferik has posted.
def twitter_user_exists?(user)
Twitter.user(user)
true
rescue Twitter::Error::NotFound
false
end
You can try to grab the http://twitter.com/username page and read the response to see if you get the "Sorry, that page doesn’t exist!" page.
Edit:
As #Pablo Fernandez mentioned in a comment, it will be better (faster, more reliable) to check the response header, which will be "404 not-found" if the user doesn't exist.
Using Ruby, you could install the twitter gem and then define the following method:
require 'twitter'
def user_exists?(user)
Twitter.user(user)
true
rescue Twitter::NotFound
false
end
Then, simply pass in a Twitter user name or id to your method, like so:
user_exists?("sferik") #=> true
user_exists?(7505382) #=> true
You can try:
<?php
$user = "toneid";
$contents = #file_get_contents('http://www.twitter.com/'.$user);
if (!$contents) {
// Report error
echo "Not a valid user";
} else {
// If is a valid url
echo "OK!";
}
?>
UPDATE: This API is not available since 2012.
According to the api docs you can pass an email address to the user/
show method, I would assume that if a user didn't exist you'd get back
a 404, which should allow you to determine whether or not the user
exists.
eg: http://twitter.com/users/show.xml?email=t...#example.com
result if not exist :
<?xml version="1.0" encoding="UTF-8"?>
<hash>
<request>/users/show.xml?email=tur...#example.com</request>
<error>Not found</error>
</hash