I was playing with the JS API recently and had problems setting multiple attributes on AssetCreate and this time I have a similar problem with PHP SOAP Request. Again I can easily create a simple asset with the following code remotely using PHP SOAP request but have problems figuring out the right syntax for setting asset attributes (e.g. simple_edit_user). Tried multistructured arrays with no result.
Not answering your question directly, but in response to:
[quote]I was playing with the JS API recently and had problems setting multiple attributes on AssetCreate[/quote]
You can use the recent addition of the 'enhanced' JS API to create assets and set attributes (and any other JS API function) all in the one http request now. Here is a quick example, asset #429 is my parent asset:
var api = new Squiz_Matrix_API({
key: "1234567890"
});
api.batchRequest({
functions: {
"0": {
"function": "createAsset",
args: {
id: 429,
type_code: "page_standard",
asset_name: "Test Asset"
}
},
"1": {
"function": "getAttributes",
args: {
id: "%results_0_id%"
}
},
"2": {
"function": "setMultipleAttributes",
args: {
id: "%results_0_id%",
attr_name: "name\\,short_name",
attr_val: "Brand new name\\,Brand new short name"
}
},
"3": {
"function": "getAttributes",
args: {
id: "%results_0_id%"
}
}
},
dataCallback: function(data){
console.log("Asset created with id: %s", data[0].id);
console.log("Attributes before change: %o ",data[1]);
console.log("Attributes after change: %o ",data[3]);
}
});
[quote]
Not answering your question directly, but in response to:
You can use the recent addition of the 'enhanced' JS API to create assets and set attributes (and any other JS API function) all in the one http request now. Here is a quick example, asset #429 is my parent asset:
var api = new Squiz_Matrix_API({
key: "1234567890"
});
api.batchRequest({
functions: {
"0": {
"function": "createAsset",
args: {
id: 429,
type_code: "page_standard",
asset_name: "Test Asset"
}
},
"1": {
"function": "getAttributes",
args: {
id: "%results_0_id%"
}
},
"2": {
"function": "setMultipleAttributes",
args: {
id: "%results_0_id%",
attr_name: "name\\,short_name",
attr_val: "Brand new name\\,Brand new short name"
}
},
"3": {
"function": "getAttributes",
args: {
id: "%results_0_id%"
}
}
},
dataCallback: function(data){
console.log("Asset created with id: %s", data[0].id);
console.log("Attributes before change: %o ",data[1]);
console.log("Attributes after change: %o ",data[3]);
}
});
[/quote]
That's cool. Nice way of putting all requests into one readable function. I guess that this will only work on the latest Matrix install though.