Facebook Graph API - Status updates - ios

I am currently using the Graph API to retrieve the News Feed for a user. However, some Posts of type "update" do not return any info on the original post e.g. in the result extract posted below, the story is "Joubert Nel commented on a link", but there is no info included as to what the link is, or the picture that goes with it. How can I obtain this info please?
actions = (
{
link = "https://www.facebook.com/637106301/posts/520940825396";
name = Comment;
}
);
comments = {
data = (
{
"can_remove" = 0;
"created_time" = "2014-03-15T13:06:43+0000";
from = {
id = 100000194244146;
name = "Laurie Edwards";
};
id = "520940825396_133907";
"like_count" = 2;
message = "Or you could just come home for a while!";
"user_likes" = 0;
},
);
paging = {
cursors = {
after = "MTI=";
before = "MQ==";
};
};
};
"created_time" = "2014-03-15T14:41:56+0000";
from = {
id = 637106301;
name = "Joubert Nel";
};
id = "637106301_520940825396";
likes = {
data = (
{
id = 214500098;
name = "Samuel Freilich";
},
{
);
paging = {
cursors = {
after = "OTUwMTE2OA==";
before = MjE0NTAwMDk4;
};
};
};
privacy = {
value = "";
};
story = "Joubert Nel commented on a link.";
"story_tags" = {
0 = (
{
id = 637106301;
length = 11;
name = "Joubert Nel";
offset = 0;
type = user;
}
);
};
type = status;
"updated_time" = "2014-03-15T14:41:56+0000";

is the link posted by Joubert? or using app you have permission. sounds like you don't have permission to post(link) but u have permission to Joubert activities

Related

Obj-C: NSString crashes with error "Terminating app due to uncaught exception NSInvalidArgumentException"?

For some reason, the following line in my app is returned NULL, and thus, crashes my app:
NSString *address = [session user][#"field_street_address"][#"und"][0][#"safe_value"];
Which, I don't understand, as my console below states that data is returned for field_street_address. Is there something wrong with that line that I'm just not seeing? I've been staring at this for a while and I feel like I'm missing something obvious.
ViewController.m
NSDictionary *userDictInfo = (NSDictionary*) [NSKeyedUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] objectForKey:#"diosSession"]];
DIOSSession *session = [DIOSSession sharedSession];
[session setUser:userDictInfo];
[session user];
NSString *address = [session user][#"field_street_address"][#"und"][0][#"safe_value"];
Console ([session user] log):
2017-10-06 14:06:22.226970-0700 app[828:193706] {
sessid = "DRY0fOXtO_FZOIeowFVVq8oalaFnKSe";
"session_name" = SESS2bb8896be0f16543ff3c6a;
token = giCdHBuw967IaSxDB34m0Evzf1HI3DIK6;
user = {
access = 1507310936;
created = 1459875505;
data = {
"ckeditor_auto_lang" = t;
"ckeditor_default" = t;
"ckeditor_lang" = en;
"ckeditor_show_toggle" = t;
"ckeditor_width" = "100%";
};
"field_address" = {
und = (
{
format = "<null>";
"safe_value" = "1325 Fake Street";
value = "1325 Fake Street";
}
);
};
"field_childrenunder" = {
und = (
{
format = "<null>";
"safe_value" = No;
value = No;
}
);
};
"field_city" = {
und = (
{
format = "<null>";
"safe_value" = Van;
value = Van;
}
);
};
"field_emergency_facility" = {
und = (
{
format = "<null>";
"safe_value" = Yes;
value = Yes;
}
);
};
"field_first_name" = {
und = (
{
format = "<null>";
"safe_value" = Brittany;
value = Brittany;
}
);
};
"field_last_name" = {
und = (
{
format = "<null>";
"safe_value" = B;
value = B;
}
);
};
"field_phonenumber" = {
und = (
{
format = "<null>";
"safe_value" = 2369893091;
value = 2369893091;
}
);
};
"field_photo_path" = {
und = (
{
format = "<null>";
"safe_value" = "sites/default/files/stored/1507092784.jpg";
value = "sites/default/files/stored/1507092784.jpg";
}
);
};
"field_points_balance" = {
und = (
{
format = "<null>";
"safe_value" = 12;
value = 12;
}
);
};
"field_postal_code" = {
und = (
{
format = "<null>";
"safe_value" = 000000;
value = 000000;
}
);
};
"field_private_message_notify" = {
und = (
{
value = 1;
}
);
};
"field_profile_photo" = {
und = (
{
alt = "";
fid = 237;
"field_file_image_alt_text" = (
);
"field_file_image_title_text" = (
);
filemime = "image/jpeg";
filename = "1507092784.jpg";
filesize = 16084;
height = 296;
metadata = {
height = 296;
width = 300;
};
"rdf_mapping" = (
);
status = 1;
timestamp = 1507108254;
title = "";
type = image;
uid = 47;
uri = "public://stored/1507092784.jpg";
width = 300;
}
);
};
"field_property_type" = {
und = (
{
format = "<null>";
"safe_value" = House;
value = House;
}
);
};
"field_province" = {
und = (
{
format = "<null>";
"safe_value" = BC;
value = BC;
}
);
};
"field_special_skills" = {
und = (
{
format = "<null>";
"safe_value" = "Oral medication";
value = "Oral medication";
}
);
};
"field_star_rating" = {
und = (
{
format = "<null>";
"safe_value" = 1;
value = 1;
}
);
};
"field_street_address" = {
und = (
{
format = "<null>";
"safe_value" = "1325 Fake Street";
value = "1325 Fake Street";
}
);
};
"field_supervision" = {
und = (
{
format = "<null>";
"safe_value" = No;
value = No;
}
);
};
"field_userbio" = {
und = (
{
format = "<null>";
"safe_value" = "Hi my name is Brittany.";
value = "Hi my name is Brittany.";
}
);
};
language = "";
login = 1507320712;
mail = "brittany-b#shaw.ca";
name = Brittany;
picture = "<null>";
"rdf_mapping" = {
homepage = {
predicates = (
"foaf:page"
);
type = rel;
};
name = {
predicates = (
"foaf:name"
);
};
rdftype = (
"sioc:UserAccount"
);
};
roles = {
2 = "authenticated user";
};
signature = "";
"signature_format" = "filtered_html";
status = 1;
theme = "";
timezone = UTC;
uid = 47;
};
}
If the log output in your question is from logging [session user] then you need to first access the #"user" key.
NSString *address = [session user][#"user"][#"field_street_address"][#"und"][0][#"safe_value"];
BTW - for issues like this it really helps to break down the code:
NSDictionary *sessionUser = [session user];
NSDictionary *user = sessionUser[#"user"];
NSDicitonary *streetAddr = user[#"field_street_address"];
// etc.
Then you can see where you start getting nil and look at the previous results to determine where things are going wrong.

how to extract Elements in NSMutable Dictionary Array

my server sends me an response in hierarchy way i do no how to grab the value from that
here my sample response :
{
id = "-1";
result = (
{
keyname = "Warranty Expiry Date";
value = "06-14-2017";
}
);
},
{
id = "-1";
result = (
{
keyname = Owner;
value = "";
}
);
},
{
id = "-1";
result = (
{
keyname = Model;
value = "";
}
);
},
{
id = "-1";
result = (
{
keyname = "Price $";
value = 1000;
}
);
},
{
id = "-1";
result = (
{
keyname = Vendor;
value = "";
}
);
},
{
id = "-1";
result = (
{
keyname = "Purchase Date";
value = "";
}
);
}
)
here is sample Java code how they extracted the values
Hashtable htAttrs = (Hashtable) editedAttrHash.get(assItmId);
if (htAttrs != null) {
Set<String> keys = htAttrs.keySet();
for (String deAttr : keys) {
xmlSerializer.startTag("", "attribute");
xmlSerializer.attribute("", "keyname", deAttr);
xmlSerializer.attribute("", "value",
htAttrs.get(deAttr).toString());
xmlSerializer.endTag("", "attribute");
}
}
i need to do no how to from this structure past one day i am blocked here anyone can fix my problem
How to extract values from nsmutablearray?If it is really nsmutablearray object, then extract the values is simple.
For example, to get id of first element:
NSString firstId = response[0][#"id"]
But it seems, like for now, it is just a json object. So, you should serialize it to nsarray object first.

How to access NSArray inside a NSDictionary while parsing a xml?

I am using XMLReader to parse a xml response. I have converted the xml to a NSDictionary. Now i want to access the array named 'cTrx' inside the NSDictionary. This is my NSDictionary:
{
Envelope = {
Body = {
fRetrieveTransactionsforReversalResponse = {
fRetrieveTransactionsforReversalResult = {
pCellularNumber = {
text = 0825669995;
};
pResponseCode = {
text = 00;
};
pResponseMessage = {
text = Approved;
};
pTrx = {
cTrx = (
{
pCardHolderName = {
};
pReference = {
text = 140826121114;
};
pTransactionAccount = {
text = "364241****0016";
};
pTransactionDate = {
text = "8/26/2014 12:11:18 PM";
};
pTransactionID = {
text = 23;
};
},
{
"xsi:nil" = true;
}
);
};
};
};
};
};
}
Thanks.
You can access dictionary and array values with square brackets:
val = dictionary[#"key"];
item = array[i];
It works for nested dictionaries as well:
NSDictionary *nested = #{#"dict_key": dictionary};
dictionaryVal = nexted[#"dict_key"][#"key"];
So, in your case, you could access cTrx array in next way:
NSArray *cTrx = yourDictionary[#"Envelope"][#"Body"][#"fRetrieveTransactionsforReversalResponse"][#"pTrx"][#"cTrx"];
Long string of code :)

Change colors in devexpress charts

I am drawing a pie chart using Devexpress in my MVC project.
While doing it by default my chart generated with three colors, as below
but my client is not satisfied, with the colors of it and wanted me to change them which match with our application background, so please help me, how to do this.
Thanks in advance.
Here is my code.
settings.Name = "chart";
settings.Width = 600;
settings.Height = 250;
settings.BorderOptions.Visible = false;
Series series1 = new Series("Type", DevExpress.XtraCharts.ViewType.Pie3D);
settings.Series.Add(series1);
series1.ArgumentScaleType = ScaleType.Qualitative;
series1.ArgumentDataMember = "ClassName";
series1.ValueScaleType = ScaleType.Numerical;
series1.ValueDataMembers.AddRange(new string[] { "PercentageValues" });
series1.LegendPointOptions.PointView = PointView.ArgumentAndValues;
series1.LegendPointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
series1.LegendPointOptions.ValueNumericOptions.Precision = 0;
series1.Label.ResolveOverlappingMode = ResolveOverlappingMode.Default;
series1.Label.Visible = false;
Please refer the following code. I have successfully implemented the same for giving custom color for rangebar. I guess it will work for your case also
settings.CustomDrawSeriesPoint = (s, ev) =>
{
BarDrawOptions drawOptions = ev.SeriesDrawOptions as BarDrawOptions;
if (drawOptions == null)
return;
Color colorInTarget = Color.Blue;
double x = ev.SeriesPoint.Values[0];
double y = ev.SeriesPoint.Values[1];
if (x == 0)
{ //Do starting
colorInTarget = Color.FromArgb(159,125, 189);
}
else{
//Red - price Increase
// Green price Decrease
if (y > previousYValue)
{
colorInTarget = Color.Red; ;
}
else
{
colorInTarget = Color.Green;
}
}
previousYValue = y;
drawOptions.Color = colorInTarget;
drawOptions.FillStyle.FillMode = FillMode.Solid;
drawOptions.Border.Color = Color.Transparent;
};
you can set the theme and palette properties of the chart control. follow the links below to devexpress documentation. although the examples refers to winform application they are still avaliable in asp.net mvc controls.
http://documentation.devexpress.com/#WindowsForms/CustomDocument7433
http://documentation.devexpress.com/#WindowsForms/CustomDocument5538
// Define the chart's appearance and palette.
barChart.AppearanceName = "Dark";
barChart.PaletteName = "Opulent";
private List<StudentClass.ChartsPointsSummary> GetStudentSummaryResults()
{
var StudentId = Convert.ToInt32(Request.Params["StudentID"]);
var StudentDetailsP = CtxSM.SMISGet_StudentAttendanceDetailsByStudentId(StudentId, SessionDataManager.SessionData.LoginUserId, SessionDataManager.SessionData.AcademicYearID, SessionDataManager.SessionData.BusinessUnitId, ref outError).ToList();
var Presents = StudentDetailsP.Select(p => new { p.Months, p.Presents});
var CountsP = StudentDetailsP.Count();
List<StudentClass.ChartsPointsSummary> MT = new List<StudentClass.ChartsPointsSummary>();
foreach (var ab in Presents)
{
MT.Add(new StudentClass.ChartsPointsSummary { PresentSummaryX = ab.Months, PresentSummaryY = Convert.ToInt32(ab.Presents) });
}
var StudentDetailsA = CtxSM.SMISGet_StudentAttendanceDetailsByStudentId(StudentId, SessionDataManager.SessionData.LoginUserId, SessionDataManager.SessionData.AcademicYearID, SessionDataManager.SessionData.BusinessUnitId, ref outError).ToList();
var Absents = StudentDetailsP.Select(p => new { p.Months, p.Absents });
var CountsA = StudentDetailsA.Count();
foreach (var ab in Absents)
{
MT.Add(new StudentClass.ChartsPointsSummary { AbsentSummaryX = ab.Months, AbsentSummaryY = Convert.ToInt32(ab.Absents) });
}
var StudentDetailsL = CtxSM.SMISGet_StudentAttendanceDetailsByStudentId(StudentId, SessionDataManager.SessionData.LoginUserId, SessionDataManager.SessionData.AcademicYearID, SessionDataManager.SessionData.BusinessUnitId, ref outError).ToList();
var CountL = StudentDetailsL.Count();
var Leaves = StudentDetailsP.Select(p => new { p.Months, p.Leaves });
foreach (var ab in Leaves)
{
MT.Add(new StudentClass.ChartsPointsSummary { LeaveSummaryX = ab.Months, LeaveSummaryY = Convert.ToInt32(ab.Leaves) });
}
return MT;
}
#Html.DevExpress().Chart(settings =>
{
settings.Name = "SummaryDetailsById";
settings.Width = 1032;
settings.Height = 250;
Series chartSeries = new Series("Presents", DevExpress.XtraCharts.ViewType.Bar);
chartSeries.ArgumentDataMember = "PresentSummaryX";
chartSeries.ValueDataMembers[0] = "PresentSummaryY";
settings.Series.Add(chartSeries);
Series chartSeries2 = new Series("Absents", DevExpress.XtraCharts.ViewType.Bar);
chartSeries2.ArgumentDataMember = "AbsentSummaryX";
chartSeries2.ValueDataMembers[0] = "AbsentSummaryY";
settings.Series.Add(chartSeries2);
Series chartSeries3 = new Series("Leaves", DevExpress.XtraCharts.ViewType.Bar);
chartSeries3.ArgumentDataMember = "LeaveSummaryX";
chartSeries3.ValueDataMembers[0] = "LeaveSummaryY";
settings.Series.Add(chartSeries3);
settings.CrosshairEnabled = DefaultBoolean.Default;
settings.BackColor = System.Drawing.Color.Transparent;
settings.BorderOptions.Visibility = DefaultBoolean.True;
settings.Titles.Add(new ChartTitle()
{
Text = "Student Attendance Summary"
});
XYDiagram diagram = ((XYDiagram)settings.Diagram);
diagram.AxisX.Label.Angle = -30;
diagram.AxisY.Interlaced = true;
}).Bind(Model).GetHtml()

How to write ItemQuery using ListIdSet?

I have requirement to retrive Item information for multiple Ids, I am using ItemQuery for the same using below code,but its gives error as "{"Invalid or missing value of the choice identifier 'ItemsElementName' of type 'Intuit.Ipp.Data.Qbd.ItemsChoiceType4[]'."}".
Please suggest if anyone is having any idea about how to use ListIdSet for ItemQuery .
List<Intuit.Ipp.Data.Qbd.IdType> ids = new List<Intuit.Ipp.Data.Qbd.IdType>();
ids.Add(new Intuit.Ipp.Data.Qbd.IdType() { Value = "123460", idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.NG });
ids.Add(new Intuit.Ipp.Data.Qbd.IdType() { Value = "789100", idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.NG });
ids.Add(new Intuit.Ipp.Data.Qbd.IdType() { Value = "111213", idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.NG });
Intuit.Ipp.Data.Qbd.ItemQuery qbdQuery = new Intuit.Ipp.Data.Qbd.ItemQuery();
List<Intuit.Ipp.Data.Qbd.Item> itemQueryResult = null;
qbdQuery.Items = ids.ToArray();
qbdQuery.ItemsElementName = new ItemsChoiceType4[] { ItemsChoiceType4.ListIdSet};
itemQueryResult = qbdQuery.ExecuteQuery<Intuit.Ipp.Data.Qbd.Item>(context).ToList<Intuit.Ipp.Data.Qbd.Item>();
Regards,
Reshma D.
Here is an example
ItemQuery qbdItemQuery = new ItemQuery();
qbdItemQuery.Items = new object[] { new IdSet() { Id = new IdType[] { new IdType() { idDomain = idDomainEnum.NG, Value = "79841" } } } };
qbdItemQuery.ItemsElementName = new ItemsChoiceType4[] { ItemsChoiceType4.ListIdSet };
List<Item> ItemQueryResult = qbdItemQuery.ExecuteQuery<Item>(context).ToList<Item>();

Resources