MySpace PeopleRequest

From ZeroPain's Wiki

Jump to: navigation, search

I meant to post this earlier but here it is If you get this error

"Request contains not implemented fields:remove"

replace remove with other options i have see its because of array.prototypes from javascript librarys

trying to run code like this

var request = opensocial.newDataRequest();
var ProFileDetails = [opensocial.Person.Field.ABOUT_ME, opensocial.Person.Field.AGE, opensocial.Person.Field.BODY_TYPE, opensocial.Person.Field.BOOKS, opensocial.Person.Field.CHILDREN, opensocial.Person.Field.CURRENT_LOCATION, opensocial.Person.Field.DATE_OF_BIRTH, opensocial.Person.Field.DRINKER, opensocial.Person.Field.ETHNICITY, opensocial.Person.Field.GENDER, opensocial.Person.Field.HAS_APP, opensocial.Person.Field.HEROES, opensocial.Person.Field.ID, opensocial.Person.Field.INTERESTS, opensocial.Person.Field.JOBS, opensocial.Person.Field.LOOKING_FOR, opensocial.Person.Field.MOVIES, opensocial.Person.Field.MUSIC, opensocial.Person.Field.NAME, opensocial.Person.Field.NETWORK_PRESENCE, opensocial.Person.Field.NICKNAME, opensocial.Person.Field.PROFILE_SONG, opensocial.Person.Field.PROFILE_URL, opensocial.Person.Field.RELATIONSHIP_STATUS, opensocial.Person.Field.RELIGION, opensocial.Person.Field.SEXUAL_ORIENTATION, opensocial.Person.Field.SMOKER, opensocial.Person.Field.STATUS, opensocial.Person.Field.THUMBNAIL_URL, opensocial.Person.Field.TV_SHOWS, opensocial.Person.Field.URLS, MyOpenSpace.Person.Field.MEDIUM_IMAGE, MyOpenSpace.Person.Field.LARGE_IMAGE];
var optParams = {};
optParams[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] = ProFileDetails;
request.add(request.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER), 'viewer');
request.add(request.newFetchPersonRequest(opensocial.IdSpec.PersonId.OWNER), 'owner');
request.add(request.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER, optParams), 'viewer2');
request.add(request.newFetchPersonRequest(opensocial.IdSpec.PersonId.OWNER, optParams), 'owner2');
request.send(function(data) {
	var viewer = data.get("viewer").getData();
	var owner = data.get("owner").getData();
	var viewer2 = data.get("viewer2").getData();
	var owner2 = data.get("owner2").getData();
	console.log(data, viewer, owner, viewer2, owner2);
});

Add this code before all your javascript and it should fix the error that is in myspaces javascript

MyOpenSpace.MySpaceContainer.prototype.mapPersonDetails_ = function(G) {
	var E = G && G[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS];
	if (!E) {
		return {
			fields: MyOpenSpace.DataRequest.Constants.BASIC_PERSON_FIELDS,
			unsupported: null
		}
	}
	var C = [];
	var F = [];
	C[opensocial.Person.Field.ID] = opensocial.Person.Field.ID;
	C[opensocial.Person.Field.NAME] = MyOpenSpace.DataRequest.Constants.NAME_FIELDS;
	C[opensocial.Person.Field.NICKNAME] = opensocial.Person.Field.NICKNAME;
	C[opensocial.Person.Field.THUMBNAIL_URL] = opensocial.Person.Field.THUMBNAIL_URL;
	C[opensocial.Person.Field.PROFILE_URL] = opensocial.Person.Field.PROFILE_URL;
	var B = opensocial.getEnvironment();
	for (var D = 0; D < E.length; D++) {
		switch (E[D]) {
			case opensocial.Person.Field.NAME:
				C[opensocial.Person.Field.NAME] = MyOpenSpace.DataRequest.Constants.NAME_FIELDS;
				break;
			case opensocial.Person.Field.JOBS:
				C[opensocial.Person.Field.JOBS] = "organizations";
				break;
			case MyOpenSpace.Person.Field.LARGE_IMAGE:
			case MyOpenSpace.Person.Field.MEDIUM_IMAGE:
				C.photos = "photos";
				break;
			default:
				if (B.supportsField(opensocial.Environment.ObjectType.PERSON, E[D])) {
					C[E[D]] = E[D]
				} else {
					F[E[D]] = true
				}
				break
		}
	}
	unsupportedStr = "";
	for (var D in F) {
		if (F.hasOwnProperty(D)) {
			unsupportedStr += D + ", "
		}
	}
	if (unsupportedStr === "") {
		unsupportedStr = null
	} else {
		unsupportedStr = unsupportedStr.substr(0, unsupportedStr.length - 2)
	}
	if (Array.sort) {
		C = Array.sort(C)
	} else {
		C = C.sort(C)
	}
	var A = "";
	for (var D in C) {
		if (C.hasOwnProperty(D)) {
			A += C[D] + ","
		}
	}
	A = A.substr(0, A.length - 1);
	return {
		fields: A,
		unsupported: unsupportedStr
	}
};

I hope this helps i just wish it didn't take me as long to find it feel like i wasted to much time before i even figured out where the error was coming from. Not to mention finding a way to fix it. As i'm still not a expert yet with javascript. But i'm working on it

Personal tools
Google AdSense