-
Brendan


- Joined on 02-02-2008
- Posts 19
|
OS 0.8: fetch person treats Array.prototype function as requested PROFILE_DETAILS
-
Summary
If you use the Prototype javascript library, the execution of a newFetchPersonRequest created with PROFILE_DETAILS fails. This happens because MyOpenSpace incorrectly views Prototype's Array extensions as requested fields.
-
Example (can be added via http://brendan.ilike.com/gadgets/myspace_test.xml)
<script type="text/javascript" src="http://s1.ilike.com/js/prototype.js"></script>
<script type="text/javascript">
<!--
function doIt() {
var req = opensocial.newDataRequest();
var params = {};
// Ask for the profile url
params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] = [opensocial.Person.Field.PROFILE_URL];
// Ask for the owner
req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.OWNER, params), 'owner');
var callback = function(response) {
// process response
var owner = response.get('owner');
var responseEl = document.getElementById('response');
responseEl.innerHTML = "global error? " + response.hadError() +
"<br/>global error message: " + response.getErrorMessage() +
"<br/>owner error? " + owner.hadError() +
"<br/>owner error message: " + owner.getErrorMessage();
};
req.send(callback);
}
setTimeout(doIt, 500);
// -->
</script>
<div id="response">No response received yet...</div>
-
Expected result
Regardless of whether prototype.js is included, the response div should say that no errors occurred. This is a valid call.
-
Actual result
If you include prototype.js, you'll receive the following error message: "Request contains not implemented fields:each, eachSlice, all, any, collect, detect, findAll, grep, include, inGroupsOf, inject, invoke, max, min, partition, pluck, reject, sortBy, toArray, zip, size, inspect, find, select, member, entries, _reverse, _each, clear, first, last, compact, flatten, without, uniq, intersect, clone, toJSON".
These values are utility functions that Prototype adds to Javascript arrays. They should not be interpreted as requested fields for the PROFILE_DETAILS parameter.
If you omit prototype.js, the call completes as expected.
-
Related
There is another brief report of this issue with some workaround code. However, it involves monkey patching the MyOpenSpace javascript, which I'm sure is against the TOS and is qutie obviously prone to breaking.
Instead of simply letting developeres work around this, MySpace should make sure the 0.8 code is compatible with Prototype. This works in 0.7.
|
|