How to get Facebook ID from the Parse User object - parse-platform

There are Parse user objects created through siging up with Facebook. How can I retrive the Facebook ID from these user objects?
As you can see the Parse User object has Facebook ID in the authData field.

You need to call Parse.Cloud.useMasterKey() before accessing authData.
Parse.Cloud.useMasterKey();
new Parse.Query(Parse.User).get(objectId).then(function(user) {
var authData = user.get("authData");
console.log(authData.facebook.id);
}
For more example, you can visit https://loginexample.parseapp.com/ which I built one month ago.

Related

How to Get all (user followings posts) in django rest framework views

relative to this answer: How to make follower-following system with django model
I will like to know how to get all the post of the user that I'm following just in case I'll want to add that extra functionality in the future.
You will have an another Model Post associated with User.
class Post(models.Model):
description = models.TextField()
user = models.ForeignKey("User", related_name="posts")
Getting all posts of following_user_id, you can achieve by below query
following_user_ids = request.user.followers.all().values_list("following_user_id", flat=True)
posts = Post.objects.filter(user__in=following_user_ids)
request.user is the logged-in user, related_name="followers" is used get all associated records from UserFollowing Model. values_list() will return the following_user_id in list form than pass the returned list in Post

Parse: Retrive all Objects where user is in a relation

I have a Parse Object Event it contain a key attendees, a Parse Relation object. My question is how to retrieve all event where current user is in the attendees relation ? my current code is :
var query = new Parse.Query(Event).equalTo('attendees',currentUser)
query.find({
success:function(list){
}
})
Your query seems Ok, try to verify your data in DB.
cmd from mongo shell
db.getCollection('_Join:attendees:Event').find({'relatedId':currentuserId})

Parse Android: update ParseObject containing an array of ParseUsers throws UserCannotBeAlteredWithoutSessionError

im working on an Android App.
I have a custom class which has relations with TWO ParseUsers and other fields. As suggested by the docs, I used an array (with key "usersArray") to store the pointers for the two ParseUsers, because I want to be able to use "include" to include the users when i query my custom class. I can create a new object and save it successfully.
//My custom parse class:
CustomObject customObject = new CustomObject();
ArrayList<ParseUser> users = new ArrayList<ParseUser>();
users.add(ParseUser.getCurrentUser());
users.add(anotherUser);
customObject.put("usersArray", users);
//I also store other variable which i would like to update later
customObject.put("otherVariable",false);
customObject.saveInBackground();
Also, i can query successfully with:
ParseQuery<CustomObject> query = CustomObject.getQuery();
query.whereEqualTo("usersArray", ParseUser.getCurrentUser());
query.whereEqualTo("usersArray", anotherUser);
query.include("usersArray");
query.findInBackground( .... );
My problem is when trying to UPDATE one of those CustomObject.
So after retrieving the CustomObject with the previous query, if I try to change the value of the "otherVariable" to true and save the object, I am getting a UserCannotBeAlteredWithoutSessionError or java.lang.IllegalArgumentException: Cannot save a ParseUser that is not authenticated exceptions.
CustomObject customObject = customObject.get(0); //From the query
customObject.put("otherVariable", true);
customObject.saveInBackground(); // EXCEPTION
I can see this is somehow related to the fact im trying to update an object which contains a pointer to a ParseUser. But im NOT modifying the user, i just want to update one of the fields of the CustomObject.
¿There is any way to solve this problem?
Maybe late but Parse users have ACL of public read and private write so you should do users.isAuthenticated() to check if its true or false.
If false then login with the user and retry. Note: you cannot edit info on two users at the same time without logging out and relogging in.
Another thing you can do is use Roles and define an admin role by using ACL which can write over all users.

Public image url from Google Gdata Contacts API

I'm trying to display related users through the Google GData Contacts API.
URL feedUrl = new URL("https://www.google.com/m8/feeds/contacts/default/full");
Query q = new Query(feedUrl);
q.setMaxResults(max);
q.setUpdatedMin(q.getUpdatedMin());
ContactFeed feed = client.query(q, ContactFeed.class);
for(ContactEntry item : feed.getEntries()){
[...]
}
I know that there is a public image url for profiles on Google.
https://www.google.com/s2/photos/profile/{user_id}
https://plus.google.com/s2/photos/profile/{user_id}
https://profiles.google.com/s2/photos/profile/{user_id}
However, when I retrieve a user's contacts, there just doesn't seem to be a field available to reference that user_id.

ASP.NET MVC / AX - Custom Membership Provider

I am new to ASP.NET MVC Forms Authentication and have just started to create my own Custom Membership Provider. My ValidateUser and ChangePassword methods work but now I want to use the GetUser method to return the current user's data throughout my site. My AX method returns an AxaptaRecord which contains details of the user, like their phone number, company name etc.. How would I use this with the GetUser method?
You just need to create a new instance of MembershipUser object and populate properties from the AxaptaRecord object, here is some pseudocode:
MembershipUser user = new MembershipUser("AX",
(string)axRecord.get_Field("name"),
axRecord.get_Field("recid"),
email, //get this from SysUserInfo table
string.Empty,
string.Empty,
(bool)axRecord.get_Field("enable"),
!(bool)axRecord.get_Field("enable"),
(DateTime)Convert.ChangeType(axRecord.get_Field("createdDateTime"), typeof(DateTime)),
DateTime.MinValue,
DateTime.MinValue,
DateTime.MinValue,
DateTime.MinValue);
Then you return user from your GetUser method. See the GetUser method description here: http://msdn.microsoft.com/en-us/library/f1kyba5e.aspx
Controller:
var userDetails = System.Web.Security.Membership.GetUser(username);
Then, there are many different ways for you to pass the data to View.
Each way has its advantage and disadvantage.
For details, please click here.
Model strongly-typed view can let you easily handle validation and generate data but not very good in display data if you have more than one table.

Resources