Adding Facebook user's profile data using Parse? - facebook

I tried to follow the tutorial “Integrating Parse-Facebook in Unity” at: https://www.parse.com/tutorials/integrating-facebook-in-unity
Everything works fine but when I want to add user’s email, gender, name, birthday and location. , by using the following method :
private IEnumerator saveUserProfile(Dictionary<string, string> profile) {
var user = ParseUser.CurrentUser;
user["profile"] = profile;
user["email"] = profile["email"] ;
user["gender"] = profile["gender"] ;
user["name"] = profile["name"] ;
user["birthday"] = profile["birthday"] ;
user["location"] = profile["location"] ;
// Save if there have been any updates
if (user.IsKeyDirty("profile")) {
var saveTask = user.SaveAsync();
while (!saveTask.IsCompleted) yield return null;
UpdateProfile();
}
}
The only value added is “gender” and the other values were NOT created. Please see the below screenshot:
Also , when I presses on Facebook :” Profile No.” row in “authData” column in Parse database side , the Facebook website open with the following message :
Profile Unavailable
Sorry, this profile is not available at the moment. Please try again shortly
Please what I can do to add the above values and to get the correct profile no. for the users
Thank you
Waheed

try to check your dictionary what are the things being stored.
foreach( KeyValuePair<string, string> kvp in profile)
{
Debug.Log("Key = " + kvp.Key + " Value = " + kvp.Value);
}

Related

redirecting users according to their group or name in Google Sites

I am trying to make a site using Google Sites, and i need a way to know the user name or group and then redirect them to different pages.
Also if you have any Google script that can help, that will be great too, thanks.
This is a very simple answer but it can help.
We just need to get the user ID and compare it to the list of authorized users, if user is in the list then a link is created, if not, a label is created telling the user they need permission.
I don't need more than that for now, but in the future 2 more features can be cool to add:
1- using group names instead of an array with users to be more dynamic. (i don't know how yet)
2- auto redirect user instead of displaying a link. (i think that can be easy)
function doGet() {
var app = UiApp.createApplication();
var arr = new Array(4);
arr[0] = "user_001#company.com";
arr[1] = "user_002#company.com";
arr[2] = "user_003#company.com";
arr[3] = "user_004#company.com";
for (var i = 0; i < arr.length; i++) {
if (Session.getActiveUser().getUserLoginId() == arr[i]){
var label = app.createLabel('User: ' + Session.getActiveUser().getUserLoginId() + ', You have permission :)');//false
var link = app.createAnchor('Here is your link', 'http://www.umich.edu').setId("link").setVisible(true);//false
var flag = 1;
break;
//#####################
} else {
var label = app.createLabel('You need permission :(');//false
var flag = 0;
}
}
app.add(label);
if (flag == 1){app.add(link);}
return app;
}

Can the Insufficient permission message in Google sites be changed or customized?

I am using Google Sites, and if a user does not have the right to view a page they get a message that says "You need permission" or "Insufficient permission".
Can this message be edited or customized?
Or even can this unauthorized user be redirected to another page automatically?
Is there a script that might help?
I got this for the second part of the question but still couldn't find an answer for the first part even in Google documentation.
This is a very simple answer but it helped. We just need to get the user ID and compare it to the list of authorized users, if user is in the list then a link is created, if not, a label is created telling the user they need permission.
function doGet() {
var app = UiApp.createApplication();
var arr = new Array(4);
arr[0] = "user_001#company.com";
arr[1] = "user_002#company.com";
arr[2] = "user_003#company.com";
arr[3] = "user_004#company.com";
for (var i = 0; i < arr.length; i++) {
if (Session.getActiveUser().getUserLoginId() == arr[i]){
var label = app.createLabel('User: ' + Session.getActiveUser().getUserLoginId() + ', You have permission :)');//false
var link = app.createAnchor('Here is your link', 'http://www.umich.edu').setId("link").setVisible(true);//false
var flag = 1;
break;
//#####################
} else {
var label = app.createLabel('You need permission :(');//false
var flag = 0;
}
}
app.add(label);
if (flag == 1){app.add(link);}
return app;
}

Android CalendarContract.Events.UID_2445 not populated

I am working an app that read Events of a given calendar.
public static final String[] EVENT_PROJECTION = new String[] {
Events._ID, // 0
Events.UID_2445, //1
Events.DTSTART, // 2
Events.DTEND }; // 3
// The indices for the projection array above.
private static final int PROJECTION_ID_INDEX = 0;
private static final int PROJECTION_UID_INDEX = 1;
...
ContentResolver contentResolver = ctx.getContentResolver();
Uri uri = Events.CONTENT_URI;
Cursor cur = contentResolver.query(uri,
EVENT_PROJECTION, Events.CALENDAR_ID + " = ?",
new String[] { String.valueOf(calendarId) }, null);
The calendar is synched to google calendar or Exchange Server mailbox. I am able to get the event using the code above, but the I noticed that Events.UID_2445 attribute is never populated.
String uid = cur.getString(PROJECTION_UID_INDEX)); //this line always returns null
Using google calendar data api and exchange web services, I have confirmed that it has ICAL UID attribute populated. It looks like calendar sync does not store that attribute in the Event object. Does anyone else have the same issue or do you see anything wrong with the code that I use? Thanks

ga:landingPagePath Issue

I need help getting the landingpage for a session using google analytics ga:landingPagePath.
When i use the query below I get the correct result with my first visit using IE. However, when I close IE and open Firefox and visit a different landing page, I still get the landing page of the previous session. I should get the landing page of the current firefox session unless since this is a new browser session. Thanks in advance for any help.
// query google analytics
var query1 = new Google.GData.Analytics.DataQuery(dataFeedUrl);
query1.Ids = string.Format("ga:{0}", profileId);
query1.Metrics = "ga:entrances";
query1.Dimensions = "ga:landingPagePath";
//query1.Filters = "ga:entrances==1";
//query.Filters = string.Format("ga:pagePath=={0}", url);
// set from and to date (google does not accept datetime min/max value)
string fromDate = DateTime.Today.ToString("yyyy-MM-dd");
query1.GAStartDate = fromDate;
query1.GAEndDate = DateTime.Today.AddDays(1).ToString("yyyy-MM-dd");
var dataFeed = service.Query(query1);
if (dataFeed != null && dataFeed.Entries != null && dataFeed.Entries.Count > 0)
{
var dataEntries = dataFeed.Entries.Last() as Google.GData.Analytics.DataEntry;
var landingPage = dataEntries;
result = landingPage.Dimensions.Last().Value.ToString();
HttpContext.Current.Session["landing"] = result.ToString();
}
return result;
}

Apex Trigger Works, can not get test pass

I came back to this 3 hours later and with no changes to any code, test execution worked.
Disregard This Question
I have written a trigger that works great for setting the accountID on a contact record based on an external ID.
I had a test that worked great, but I added some logic to the trigger so it only updates contacts with a 'Default Account' as account. Now my test fails saying it did not update the account even though it still works as designed when saving records.
What am I missing?
I added line 4
ID DefaultAccID = [select ID from Account where Name = 'Default Account'].ID;
and the if around line 9
if (contactNew.AccountID == DefaultAccID) {
}
to Trigger:
trigger TRG_Contact_SetHouseholdID on Contact (before update, before insert) {
Set<String> AccIDlist = new Set<String>();
ID DefaultAccID = [select ID from Account where Name = 'Default Account'].ID;
// loop through records finding thoes that need to be linked
for(Contact contactNew:Trigger.New){
if (contactNew.AccountID == DefaultAccID) {
AccIDlist.add(contactNew.RPHouseholdID__c);
}
}
Map<String, ID> AccountMap = new Map<String, ID>();
//loop needing linked and get account ID if it exist
for(Account oneAccount:[SELECT RPHouseholdID__c, ID from Account where RPHouseholdID__c IN :AccIDlist]){
AccountMap.put(oneAccount.RPHouseholdID__c, oneAccount.ID);
}
// loop through records updating the ones that need link
for(Contact contactNew:Trigger.New){
if (AccountMap.get(contactNew.RPHouseholdID__c) <> null){
contactNew.AccountID = AccountMap.get(contactNew.RPHouseholdID__c);
}
}
}
Test Class:
#isTest
Private class TRG_Contact_SetHouseholdID_Test {
static TestMethod void Test0_TestInsertWithValue(){
insertTestAccounts();
Account defaultAccount = [select ID from Account where name = 'Default Account' limit 1];
Account newAccount = [select ID from Account where name = 'Camper Family' limit 1];
test.startTest();
insertTestContact(defaultAccount.ID);
test.stopTest();
Contact newContact = [select ID,AccountID from Contact where firstname = 'Happy' and lastname = 'Camper' limit 1];
System.assertEquals(newContact.AccountID, newAccount.ID, 'accountID did not get changed from default (' + defaultAccount.ID + ')');
}
private static void insertTestAccounts()
{
Account obj = new Account();
obj.Name = 'Default Account';
insert obj;
obj = new Account() ;
obj.Name = 'Camper Family';
obj.RPHouseholdID__c = '111';
insert obj;
}
private static void insertTestContact(ID defaultID)
{
Contact obj = new Contact();
obj.AccountID = defaultID;
obj.firstName = 'Happy';
obj.lastname = 'Camper';
obj.RPHouseholdID__c = '111';
insert obj;
}
}
Expanding a bit on #zachelrath 's answer, beginning with API version 24.0, test methods are isolated from the data in the organization (with a few exceptions User, RecordType, etc. see here for the full list). Rather than changing the API version of the file, the easiest thing to do is to add the see all data directive to the isTest annotation, like so:
#isTest(SeeAllData=true)
Private class TRG_Contact_SetHouseholdID_Test {
// etc
Set your test class' API version to 24.0 --- I'd bet your initial query for the Default Account is pulling in a preexisting record whose Name is 'Default Account', instead of the Default Account you're creating in your test data. There are 2 ways to get around this:
(Easiest) Change your test class to API version 24.0
If you would rather stay in API 23.0 or lower, then, at the start of your test method, delete all accounts named 'Default Account', then insert your test accounts.