I'm trying to figure out how to parse some Facebook JSON data I get back using graphPath:#"me/home".
Im assuming the data returned from
FBRequest *request = [[FBRequest alloc] initWithSession:FBSession.activeSession
graphPath:#"me/home"];
doesn't need parsing, and i just need to extract the data through dictionary keys, im finding this pretty confusing. Im trying to put the data into a tableview, basically showing the users news feed from Facebook. Heres a snippet of data returned:
"data": [
{
"id": "1156410856_4453627016238",
"from": {
"name": "Abbi ☆ Mathews",
"id": "1156410856"
},
"message": "Aalllllllll over this tonight.......be there....gonna be booooom ting!",
"picture": "http://photos-a.ak.fbcdn.net/hphotos-ak-snc6/185169_4453626736231_812066502_s.jpg",
"link": "http://www.facebook.com/photo.php?fbid=4453626736231&set=a.1166926850788.88722.1156410856&type=1&relevant_count=1",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v2/yx/r/og8V99JVf8G.gif",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/1156410856/posts/4453627016238"
},
{
"name": "Like",
"link": "http://www.facebook.com/1156410856/posts/4453627016238"
}
],
"privacy": {
"description": "Friends; Except: Restricted",
"value": "ALL_FRIENDS"
},
"type": "photo",
"object_id": "4453626736231",
"application": {
"name": "Facebook for Android",
"namespace": "fbandroid",
"id": "350685531728"
},
"created_time": "2012-08-25T14:08:11+0000",
"updated_time": "2012-08-25T14:08:11+0000",
"comments": {
"count": 0
}
},
{
"id": "7147617470_10150998196922471",
"from": {
"name": "The Fratellis",
"category": "Musician/band",
"id": "7147617470"
},
"picture": "http://platform.ak.fbcdn.net/www/app_full_proxy.php?app=123966167614127&v=1&size=z&cksum=77469f27ebc292a58b3ee8ffb8183582&src=https%3A%2F%2Fd12nfv3nknyhzq.cloudfront.net%2Fimages%2Fartists%2F1208090326852218_medium.jpg",
"link": "http://www.bandsintown.com/event/5469167/facebook_rsvp?artist=The+Fratellis&came_from=90",
"name": "Next Month: The Fratellis # Academy in Oxford, United Kingdom",
"caption": "Saturday, September 22, 2012 at 7:00pm",
"properties": [
{
"name": "Tickets",
"text": "http://bnds.in/Nq9prK",
"href": "http://www.bandsintown.com/event/5469167/buy_tickets?affil_code=fb_7147617470_auto_promote_month_before_targeted&artist=The+Fratellis"
},
{
"name": "More Tour Dates",
"text": "http://bnds.in/O9NLwd",
"href": "http://www.bandsintown.com/TheFratellis/facebookapp?came_from=90"
}
],
"icon": "http://photos-b.ak.fbcdn.net/photos-ak-snc7/v85006/251/123966167614127/app_2_123966167614127_7663.gif",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/7147617470/posts/10150998196922471"
},
{
"name": "Like",
"link": "http://www.facebook.com/7147617470/posts/10150998196922471"
},
{
"name": "RSVP",
"link": "http://www.bandsintown.com/event/5469167/facebook_rsvp?artist=The+Fratellis&came_from=90"
}
],
"privacy": {
"description": "United Kingdom",
"value": "CUSTOM"
},
"type": "link",
"application": {
"name": "Bandsintown",
"namespace": "concertsbybit",
"id": "123966167614127"
},
"created_time": "2012-08-25T14:06:39+0000",
"updated_time": "2012-08-25T14:14:01+0000",
"likes": {
"data": [
{
"name": "Derek Moore",
"id": "536043117"
},
{
"name": "Louise Berry",
"id": "1310689257"
},
{
"name": "Jack Barber",
"id": "100002857426027"
},
{
"name": "Becky Hoddinott",
"id": "100000168277953"
}
],
"count": 8
},
"comments": {
"data": [
{
"id": "7147617470_10150998196922471_22699715",
"from": {
"name": "Becky Hoddinott",
"id": "100000168277953"
},
"message": "Yesssssss! <3",
"created_time": "2012-08-25T14:14:01+0000"
}
],
"count": 1
}
},
{
Ive been trying to put this into a tableview, but the UILabels are just blank, so what keys do i use to get this to work??
Heres All the Code:
-(void)sendRequests {
FBRequestConnection *connection = [[FBRequestConnection alloc] init];
FBRequest *request = [[FBRequest alloc] initWithSession:FBSession.activeSession
graphPath:#"me/home"];
[connection addRequest:request completionHandler:
^(FBRequestConnection *connection, id result, NSError *error) {
if (!error && result) {
NSLog(#"Pre Parsed Data = %#", result);
NSArray *arrayRsult = [result objectForKey:#"data"];
for (_FBData in arrayRsult){
[self.tableView reloadData];
}
} else if (error) {
NSLog(#"Error Fetching Data = %#", error);
}
}];
[connection start];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
FaceBookCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[FaceBookCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
NSLog(#"Intialise Cell");
}
NSMutableDictionary *fbText = [_FBData objectAtIndex:indexPath.row];
NSString *name = [[fbText objectForKey:#"from"] objectForKey:#"name"];
NSString *dateCreated = [fbText objectForKey:#"created_time"];
NSString *message = [fbText objectForKey:#"message"];
[cell.name setText:name];
[cell.message setText:message];
[cell.time setText:dateCreated];
NSLog(#"Names = %#", name);
return cell;
}
Related
I am learning ES and I am having problems with this query:
Given 2 products:
products/_source/1
{
"product_id": "58410-2",
"name": [
{
"locale": "en",
"translation": "CBC panel"
},
{
"locale": "vn",
"translation": "CBC panel VN"
}
],
"status": "active",
"category": {
"id": 8,
"name": [
{
"locale": "en",
"translation": "Hematology"
},
{
"locale": "vn",
"translation": "huyết học"
}
]
},
"children": [
{
"product_id": "6690-2",
"name": [
{
"locale": "en",
"translation": "Leukocytes"
},
{
"locale": "vn",
"translation": "Leukocytes vn"
}
],
"status": "active",
"category": {
"id": 8,
"name": [
{
"locale": "en",
"translation": "Hematology"
},
{
"locale": "vn",
"translation": "huyết học"
}
]
},
"children": []
}]}
and
products/_source/2
{
"product_id": "6690-2",
"name": [
{
"locale": "en",
"translation": "Leukocytes"
},
{
"locale": "vn",
"translation": "Leukocytes vn"
}
],
"status": "active",
"category": {
"id": 8,
"name": [
{
"locale": "en",
"translation": "Hematology"
},
{
"locale": "vn",
"translation": "huyết học"
}
]
},
"children": []
}
where a product is a single document but also can be nested in a children array of other products. Both products are different documents in the index.
and this index:
{
"products": {
"aliases": {},
"mappings": {
"dynamic": "false",
"properties": {
"category": {
"properties": {
"name": {
"properties": {
"locale": {
"type": "keyword"
},
"translation": {
"type": "text"
}
}
}
}
},
"children": {
"type": "nested"
},
"name": {
"properties": {
"locale": {
"type": "keyword"
},
"translation": {
"type": "text"
}
}
},
"product_id": {
"type": "keyword"
},
"status": {
"type": "keyword"
}
}
},
"settings": {
"index": {
"routing": {
"allocation": {
"include": {
"_tier_preference": "data_content"
}
}
},
"number_of_shards": "3",
"provided_name": "products",
"number_of_replicas": "1"
}
}
}
}
I want to be able to query for "Leuko" (or the category or the product_id) and retrieve both products, the single product and the root product.
I have tried using object field, nested, flattened but I think the problem is I don't know how to properly write the query, I have tried things like this (I am using a ruby library but I think it is easy to follow):
#query = {
query: {
query_string: {
fields: ['name.translation', 'children.name.translation', 'category.name.translation', 'children.product_id'],
query: "*#{text}*"
}
},
size: 50
}
#query = {
query: {
nested: {
path: 'children',
query: {
bool: {
should: [
term: { 'children.name.translation' => "*#{text}*" },
term: { 'name.translation' => "*#{text}*" }
]
}
}
}
}
}
but I think at some point I dunno what I am doing anymore and I am just randomly trying different stuff from the documentation.
Follow my query suggestion. Note that I had to add the fields in the Nested object to the mapping.
Mapping:
{
"mappings": {
"dynamic": "false",
"properties": {
"category": {
"properties": {
"name": {
"properties": {
"locale": {
"type": "keyword"
},
"translation": {
"type": "text"
}
}
}
}
},
"children": {
"type": "nested",
"properties": {
"product_id": {
"type": "keyword"
},
"category": {
"properties": {
"name": {
"properties": {
"locale": {
"type": "keyword"
},
"translation": {
"type": "text"
}
}
}
}
},
"name": {
"properties": {
"locale": {
"type": "keyword"
},
"translation": {
"type": "text"
}
}
},
"status": {
"type": "keyword"
}
}
},
"name": {
"properties": {
"locale": {
"type": "keyword"
},
"translation": {
"type": "text"
}
}
},
"product_id": {
"type": "keyword"
},
"status": {
"type": "keyword"
}
}
}
}
Query:
{
"query": {
"bool": {
"minimum_should_match": 1,
"should": [
{
"nested": {
"path": "children",
"query": {
"wildcard": {
"children.name.translation": "leuko*"
}
}
}
},
{
"wildcard": {
"name.translation": "leuko*"
}
}
]
}
}
}
hint
See that you use translation. Avoid using array to make your queries simpler.
What I would do in your case is to create a field for each language, this makes the use of analyzer more flexible for each type of language and you stop using an array and work with an object.
PUT test
{
"mappings": {
"properties": {
"name":{
"type": "text",
"fields": {
"es":{
"type": "text",
"analyzer":"english"
},
"vn":{
"type": "text"
}
}
}
}
}
}
POST test/_doc/
{
"name": "Leukocytes"
}
An example query using field languages.
GET test/_search
{
"query": {
"multi_match": {
"query": "Leukocytes",
"fields": ["name.es", "name.vn"]
}
}
}
Like Steve with his question, i have problem with this new API :
Unknown Error trying to add Pricing to a In App Purchase String
I followed Guide from Apple :
https://developer.apple.com/documentation/appstoreconnectapi/app_store/in-app_purchase/managing_in-app_purchases
I can change price from inAppPurchase but now i'm stuck with "Promotional Price".
For example, my inApp Puchase have a product tiers 8 at 9.99€ and from 1 November 2022 to 30 November i want a different price (product tiers 4 at 4.99€). The first of December, price will go back to 9.99€.
When testing inAppPurchasePriceSchedules POST, i have 409 error (Conflict) or 500 error.
Here one of payload i test :
{
"data": {
"relationships": {
"inAppPurchase": {
"data": {
"id": 1592386688,
"type": "inAppPurchases"
}
},
"manualPrices": {
"data": [{
"type": "inAppPurchasePrices",
"id": "${prices-id}"
}, {
"type": "inAppPurchasePrices",
"id": "${prices-id-1}"
}
]
}
},
"type": "inAppPurchasePriceSchedules"
},
"included": [{
"attributes": {
"startDate": "2022-11-01"
},
"id": "${prices-id}",
"relationships": {
"inAppPurchasePricePoint": {
"data": {
"id": "eyJzIjoiMTU5MjM4NjY4OCIsInQiOiJGUkEiLCJwIjoiMyJ9", //Tiers 5
"type": "inAppPurchasePricePoints"
}
},
"inAppPurchaseV2": {
"data": {
"id": "1592386688",
"type": "inAppPurchases"
}
}
}
}, {
"attributes": {
"startDate": "2022-12-01"
},
"id": "${prices-id-1}",
"relationships": {
"inAppPurchasePricePoint": {
"data": {
"id": "eyJzIjoiMTU5MjM4NjY4OCIsInQiOiJGUkEiLCJwIjoiNSJ9", //Tiers 10
"type": "inAppPurchasePricePoints"
}
},
"inAppPurchaseV2": {
"data": {
"id": "1592386688",
"type": "inAppPurchases"
}
}
},
"type": "inAppPurchasePrices"
}
]
}
I tried with 3 manualPrices, with "{$price1}" or "{$price2}" as id.
I tried with id from current price...
I'm missing something, I must be close by...
Update
after using Fiddler on appstoreconnect.apple.com and adding / removing promotion i was able to create this payload :
{
"data": {
"type": "inAppPurchasePriceSchedules",
"relationships": {
"inAppPurchase": {
"data": {
"type": "inAppPurchases",
"id": "1592386688"
}
},
"manualPrices": {
"data": [{
"type": "inAppPurchasePrices",
"id": "${price1}"
}, {
"type": "inAppPurchasePrices",
"id": "${price2}"
}, {
"type": "inAppPurchasePrices",
"id": "${price3}"
}
]
}
}
},
"included": [{
"type": "inAppPurchasePrices",
"id": "${price1}",
"attributes": {
"startDate": null
},
"relationships": {
"inAppPurchaseV2": {
"data": {
"type": "inAppPurchases",
"id": "1592386688"
}
},
"inAppPurchasePricePoint": {
"data": {
"type": "inAppPurchasePricePoints",
"id": "eyJzIjoiMTU5MjM4NjY4OCIsInQiOiJGUkEiLCJwIjoiNSJ9"
}
}
}
}, {
"type": "inAppPurchasePrices",
"id": "${price2}",
"attributes": {
"startDate": "2022-11-01"
},
"relationships": {
"inAppPurchaseV2": {
"data": {
"type": "inAppPurchases",
"id": "1592386688"
}
},
"inAppPurchasePricePoint": {
"data": {
"type": "inAppPurchasePricePoints",
"id": "eyJzIjoiMTU5MjM4NjY4OCIsInQiOiJGUkEiLCJwIjoiMyJ9"
}
}
}
}, {
"type": "inAppPurchasePrices",
"id": "${price3}",
"attributes": {
"startDate": "2022-12-01"
},
"relationships": {
"inAppPurchaseV2": {
"data": {
"type": "inAppPurchases",
"id": "1592386688"
}
},
"inAppPurchasePricePoint": {
"data": {
"type": "inAppPurchasePricePoints",
"id": "eyJzIjoiMTU5MjM4NjY4OCIsInQiOiJGUkEiLCJwIjoiNSJ9"
}
}
}
}
]
}
This one worked !
Thanks
Guldil
I looked over other answers that was having the same problem, but those answers don't seem to resolve this problem. How can I get the request to include the Author name? Although, this request returns Author in the response, it doesn't have the actual author details.
Am I missing something on the request or does it need some configuration adjustments?
Setup
We have ADFS configured with Sharepoint 2013 on Premise.
Endpoint I'm hitting
https://SHAREPOINTURL/_api/web/GetFolderByServerRelativeUrl('Documents')?$select=Author/Id,Author/Name,Author/Title,Editor/Id,Editor/Name,Editor/Title,*&$expand=Files/Author,Editor
Response
{
"d": {
"__metadata": {
"id": "https://SHAREPOINT_URL/_api/Web/GetFolderByServerRelativeUrl('Documents')",
"uri": "https://SHAREPOINT_URL/_api/Web/GetFolderByServerRelativeUrl('Documents')",
"type": "SP.Folder"
},
"Files": {
"results": [
{
"__metadata": {
"id": "https://SHAREPOINT_URL/_api/Web/GetFileByServerRelativeUrl('Documents/FILENAME.xls')",
"uri": "https://SHAREPOINT_URL/_api/Web/GetFileByServerRelativeUrl('Documents/FILENAME.xls')",
"type": "SP.File"
},
"Author": {
"__metadata": {
"id": "https://SHAREPOINT_URL/_api/Web/GetFileByServerRelativeUrl('Documents/FILENAME.xls')/Author",
"uri": "https://SHAREPOINT_URL/_api/Web/GetFileByServerRelativeUrl('Documents/FILENAME.xls')/Author",
"type": "SP.User"
},
"Groups": {
"__deferred": {
"uri": "https://SHAREPOINT_URL/_api/Web/GetFileByServerRelativeUrl('Documents/FILENAME.xls')/Author/Groups"
}
},
"Id": 1073741823,
"IsHiddenInUI": false,
"LoginName": "SHAREPOINT\\system",
"Title": "System Account",
"PrincipalType": 1,
"Email": "",
"IsSiteAdmin": false,
"UserId": {
"__metadata": {
"type": "SP.UserIdInfo"
},
"NameId": "S-1-0-0",
"NameIdIssuer": "urn:office:idp:activedirectory"
}
},
"CheckedOutByUser": {
"__deferred": {
"uri": "https://SHAREPOINT_URL/_api/Web/GetFileByServerRelativeUrl('Documents/FILENAME.xls')/CheckedOutByUser"
}
},
"ListItemAllFields": {
"__deferred": {
"uri": "https://SHAREPOINT_URL/_api/Web/GetFileByServerRelativeUrl('Documents/FILENAME.xls')/ListItemAllFields"
}
},
"LockedByUser": {
"__deferred": {
"uri": "https://SHAREPOINT_URL/_api/Web/GetFileByServerRelativeUrl('Documents/FILENAME.xls')/LockedByUser"
}
},
"ModifiedBy": {
"__deferred": {
"uri": "https://SHAREPOINT_URL/_api/Web/GetFileByServerRelativeUrl('Documents/FILENAME.xls')/ModifiedBy"
}
},
"Versions": {
"__deferred": {
"uri": "https://SHAREPOINT_URL/_api/Web/GetFileByServerRelativeUrl('Documents/FILENAME.xls')/Versions"
}
},
"CheckInComment": "",
"CheckOutType": 2,
"ContentTag": "{71501108-7ACC-46F6-82D7-33E5C5F0124C},3,4",
"CustomizedPageStatus": 0,
"ETag": "\"{71501108-7ACC-46F6-82D7-33E5C5F0124C},3\"",
"Exists": true,
"Length": "390144",
"Level": 1,
"MajorVersion": 1,
"MinorVersion": 0,
"Name": "FILENAME.xls",
"ServerRelativeUrl": "Documents/FILENAME.xls",
"TimeCreated": "2013-07-10T13:55:39Z",
"TimeLastModified": "2013-07-10T13:55:39Z",
"Title": "",
"UIVersion": 512,
"UIVersionLabel": "1.0"
}
]
},
"ListItemAllFields": {
"__deferred": {
"uri": "https://SHAREPOINT_URL/_api/Web/GetFolderByServerRelativeUrl('Documents')/ListItemAllFields"
}
},
"ParentFolder": {
"__deferred": {
"uri": "https://SHAREPOINT_URL/_api/Web/GetFolderByServerRelativeUrl('Documents')/ParentFolder"
}
},
"Properties": {
"__deferred": {
"uri": "https://SHAREPOINT_URL/_api/Web/GetFolderByServerRelativeUrl('Documents')/Properties"
}
},
"Folders": {
"__deferred": {
"uri": "https://SHAREPOINT_URL/_api/Web/GetFolderByServerRelativeUrl('Documents')/Folders"
}
},
"ItemCount": 18,
"Name": "Documents",
"ServerRelativeUrl": "Documents",
"WelcomePage": ""
}
}
Try this. I found this on the MSDN forum.
https://social.msdn.microsoft.com/Forums/office/en-US/04fc252c-adb9-4f50-b9b0-c326f88ad69e/retriving-author-name-using-rest-api?forum=appsforsharepoint
----- update
https://{SITE_URL}/_api/web/Lists/getbytitle('{DOCUMENT_PATH}')/items?$select=Title,Author/ID,Author/FirstName,Author/LastName,Author/Title,Author/Department,Author/EMail&$expand=Author/ID
All, I'm losing my mind. I have a class with the following code passing an NSArray of "Events" to my View Controller:
+ (NSArray *)eventsFromJSON:(NSData *)objectNotation error:(NSError **)error {
NSError *localError = nil;
NSArray *parsedObject = [NSJSONSerialization JSONObjectWithData:objectNotation options:0 error:&localError];
if (localError != nil) {
*error = localError;
return nil;
}
NSMutableArray *events = [[NSMutableArray alloc] init];
//NSArray *results = [parsedObject valueForKey:#"results"];
NSLog(#"Count %lu", (unsigned long)parsedObject.count);
for (NSDictionary *eventDic in parsedObject) {
Event *event = [[Event alloc] init];
for (NSString *key in eventDic) {
if ([event respondsToSelector:NSSelectorFromString(key)]) {
[event setValue:[eventDic valueForKey:key] forKey:key];
}
}
[events addObject:event];
}
return events;
}
On my view controller I've got the following code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"eventCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
Event *event = [self.eventData objectAtIndex:indexPath.row];
cell.textLabel.text = event.title;
cell.detailTextLabel.text = event.link;
return cell;
}
- (void) didReceiveEvents:(NSArray *)events {
self.eventData = [events copy];
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
}
A sample of the JSON I'm parsing is below:
[
{
"ID": 576,
"title": “Event Title“,
"status": "publish",
"type": "tribe_events",
"author": {
"ID": 1,
"username": "admin",
"name": "admin",
"first_name": “Name”,
"last_name": “Last”,
"nickname": "admin",
"slug": "admin",
"URL": "",
"avatar": "1.gravatar.com/avatar/",
"description": "",
"registered": "-001-11-30T00:00:00+00:00",
"meta": {
"links": {
"self": "url.com/wp-json/users/1",
"archives": "url.com/wp-json/users/1/posts"
}
}
},
"content": "<p>Join us if you are interested.</p>\n",
"parent": {
"ID": 575,
"title": “Title”,
"status": "publish",
"type": "tribe_events",
"author": {
"ID": 1,
"username": "admin",
"name": "admin",
"first_name": “First”,
"last_name": “Last”,
"nickname": "admin",
"slug": "admin",
"URL": "",
"avatar": "1.gravatar.com/avatar/?s=96",
"description": "",
"registered": "-001-11-30T00:00:00+00:00",
"meta": {
"links": {
"self": "url.com/wp-json/users/1",
"archives": "url.com/wp-json/users/1/posts"
}
}
},
"content": "<p>Join us if you are interested in joining </p>\n",
"parent": 0,
"link": "url.com/calendar/worship-service-practice/2014-12-06/",
"date": "2014-12-04T20:09:21-06:00",
"modified": "2014-12-04T20:09:21-06:00",
"format": "standard",
"slug": "worship-service-practice",
"guid": "url.com/?post_type=tribe_events&p=575",
"excerpt": "<p>Join us if you are interested i</p>\n",
"menu_order": 0,
"comment_status": "closed",
"ping_status": "closed",
"sticky": false,
"date_tz": "America/Chicago",
"date_gmt": "2014-12-05T02:09:21+00:00",
"modified_tz": "America/Chicago",
"modified_gmt": "2014-12-05T02:09:21+00:00",
"meta": {
"links": {
"self": "url.com/wp-json/posts/575",
"author": "url.com/wp-json/users/1",
"collection": "url.com/wp-json/posts",
"replies": "url.com/wp-json/posts/575/comments",
"version-history": "url.com/wp-json/posts/575/revisions"
}
},
"post_meta": {
"EventStartDate": "2014-12-06 08:00:00",
"EventEndDate": "2014-12-06 09:00:00"
},
"featured_image": null,
"terms": {
"tribe_events_cat": [
{
"ID": 13,
"name": "Community Outreach",
"slug": "community-outreach",
"description": "",
"parent": null,
"count": 52,
"link": "url.com/calendar/category/community-outreach/",
"meta": {
"links": {
"collection": "url.com/wp-json/taxonomies/tribe_events_cat/terms",
"self": "url.com/wp-json/taxonomies/tribe_events_cat/terms/9"
}
}
}
]
}
},
"link": "url.com/calendar/worship-service-practice/2014-12-13/",
"date": "2014-12-04T20:09:21-06:00",
"modified": "2014-12-04T20:09:21-06:00",
"format": "standard",
"slug": "worship-service-practice-2014-12-13",
"guid": "url.com/?post_type=tribe_events&eventDate=2014-12-13#038;p=575",
"excerpt": "<p>Join us if you are interested </p>\n",
"menu_order": 0,
"comment_status": "closed",
"ping_status": "closed",
"sticky": false,
"date_tz": "America/Chicago",
"date_gmt": "2014-12-05T02:09:21+00:00",
"modified_tz": "America/Chicago",
"modified_gmt": "2014-12-05T02:09:21+00:00",
"meta": {
"links": {
"self": "url.com/wp-json/posts/576",
"author": "url.com/wp-json/users/1",
"collection": "url.com/wp-json/posts",
"replies": "url.com/wp-json/posts/576/comments",
"version-history": "url.com/wp-json/posts/576/revisions",
"up": "url.com/wp-json/posts/575"
}
},
"post_meta": {
"EventStartDate": "2014-12-13 08:00:00",
"EventEndDate": "2014-12-13 09:00:00"
},
"featured_image": null,
"terms": {
"tribe_events_cat": [
{
"ID": 13,
"name": "Community Outreach",
"slug": "community-outreach",
"description": "",
"parent": null,
"count": 52,
"link": "url.com/calendar/category/community-outreach/",
"meta": {
"links": {
"collection": "url.com/wp-json/taxonomies/tribe_events_cat/terms",
"self": "url.com/wp-json/taxonomies/tribe_events_cat/terms/9"
}
}
}
]
}
},
{…
I can't for the life of me get the data from the Event class to display on the table. I have 10 empty rows display on the table with the disclosure indicator but no text. When I throw an NSLog into the cellForRowAtIndexPath function and attempt to print event.title it logs as null. Any ideas on what I'm doing wrong?
You never set event.title. Also the way you iterate through the json is incorrect. If it is a property you should set it like so:
for(NSDictionary *eventDic in [parsedObject objectForKey:#"results"]){
Event *event = [[Event alloc] init];
event.title = eventDic[#"title"]; //shorthand for [eventDic objectForKey:#"title"];
event.link = eventDic[#"link"];
[events addObject:event];
}
It turns out my code was fine, but when I setup my Event class I made the attributes weak vs strong. Once making the properties attributes strong, it retained all of the pointers just fine and everything was good to go.
i am working one facebook intrgation project in ios,iphone
so i am using me?fields=posts on browser is working properly
i means on this link developer account
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=me%3Ffields%3Dposts
but when i am using me?fields=posts in xcode this only return a old data not all data
here is my code so please give me solution where i am doing mistake
[FBRequestConnection startWithGraphPath:#"me?fields=posts"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSLog(#"Results: %#", result);
NSArray *post = [result valueForKey:#"posts"];
NSArray *mainData = [post valueForKey:#"data"];
/// NSLog(#"Results: show image>>>>>>> %#", [mainData valueForKey:#"picture"]);
//
NSArray *picturedata =[mainData valueForKey:#"picture"];
NSLog(#"%#",picturedata);
Here i attacha a image link also please check
image 1
in Graph api data is
{
"posts": {
"data": [
{
"id": "100005440749818_240650716126285",
"from": {
"name": "Birjesh Sharma",
"id": "100005440749818"
},
"message": "Hello\r\n\r\n\r\n",
"picture": "https://fbexternal-a.akamaihd.net/app_full_proxy.php?app=278318608948142&v=1&size=z&cksum=9c977855a08e5bde268444a1ab24a254&src=https%3A%2F%2Fraw.github.com%2Ffbsamples%2Fios-3.x-howtos%2Fmaster%2FImages%2Fiossdk_logo.png",
"link": "https://developers.facebook.com/ios",
"name": "Facebook SDK for iOS",
"caption": "Build great social apps and get more installs.",
"description": "The Facebook SDK for iOS makes it easier and faster to develop Facebook integrated iOS apps.",
"icon": "https://www.facebook.com/images/litestand/bookmarks/sidebar/icons/small/icon-app.png",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/100005440749818/posts/240650716126285"
},
{
"name": "Like",
"link": "https://www.facebook.com/100005440749818/posts/240650716126285"
}
],
"privacy": {
"description": "Friends",
"value": "ALL_FRIENDS",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"type": "link",
"status_type": "app_created_story",
"application": {
"name": "Feed Dialog How To",
"id": "278318608948142"
},
"created_time": "2014-04-26T12:59:15+0000",
"updated_time": "2014-04-26T12:59:15+0000"
},
{
"id": "100005440749818_240650712792952",
"from": {
"name": "Birjesh Sharma",
"id": "100005440749818"
},
"message": "Hello\r\n\r\n\r\n",
"picture": "https://fbexternal-a.akamaihd.net/app_full_proxy.php?app=278318608948142&v=1&size=z&cksum=9c977855a08e5bde268444a1ab24a254&src=https%3A%2F%2Fraw.github.com%2Ffbsamples%2Fios-3.x-howtos%2Fmaster%2FImages%2Fiossdk_logo.png",
"link": "https://developers.facebook.com/ios",
"name": "Facebook SDK for iOS",
"caption": "Build great social apps and get more installs.",
"description": "The Facebook SDK for iOS makes it easier and faster to develop Facebook integrated iOS apps.",
"icon": "https://www.facebook.com/images/litestand/bookmarks/sidebar/icons/small/icon-app.png",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/100005440749818/posts/240650712792952"
},
{
"name": "Like",
"link": "https://www.facebook.com/100005440749818/posts/240650712792952"
}
],
"privacy": {
"description": "Friends",
"value": "ALL_FRIENDS",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"type": "link",
"status_type": "app_created_story",
"application": {
"name": "Feed Dialog How To",
"id": "278318608948142"
},
"created_time": "2014-04-26T12:59:14+0000",
"updated_time": "2014-04-26T12:59:14+0000"
},
{
"id": "100005440749818_240643612793662",
"from": {
"name": "Birjesh Sharma",
"id": "100005440749818"
},
"message": "Hello how are you",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/100005440749818/posts/240643612793662"
},
{
"name": "Like",
"link": "https://www.facebook.com/100005440749818/posts/240643612793662"
}
],
"privacy": {
"description": "Friends",
"value": "ALL_FRIENDS",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"type": "status",
"status_type": "mobile_status_update",
"application": {
"name": "Batch Requests How To",
"id": "216458921816803"
},
"created_time": "2014-04-26T12:20:43+0000",
"updated_time": "2014-04-26T12:20:43+0000"
},
{
"id": "100005440749818_240368252821198",
"from": {
"name": "Birjesh Sharma",
"id": "100005440749818"
},
"story": "Birjesh Sharma added a new photo.",
"picture": "https://fbcdn-photos-e-a.akamaihd.net/hphotos-ak-prn2/t1.0-0/10155869_240368246154532_637168545169195821_s.jpg",
"link": "https://www.facebook.com/photo.php?fbid=240368246154532&set=a.170520606472630.1073741830.100005440749818&type=1&relevant_count=1",
"name": "HelloFBSample Photos",
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/100005440749818/posts/240368252821198"
},
{
"name": "Like",
"link": "https://www.facebook.com/100005440749818/posts/240368252821198"
}
],
"privacy": {
"description": "Only Me",
"value": "SELF",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"type": "photo",
"status_type": "added_photos",
"object_id": "240368246154532",
"application": {
"name": "HelloFBSample",
"namespace": "fbsdktemplateapp",
"id": "355198514515820"
},
"created_time": "2014-04-25T13:26:06+0000",
"updated_time": "2014-04-25T13:26:06+0000"
},
{
"id": "100005440749818_240333912824632",
"from": {
"name": "Birjesh Sharma",
"id": "100005440749818"
},
"message": "Post by nishant",
"picture": "https://fbcdn-photos-f-a.akamaihd.net/hphotos-ak-prn2/t1.0-0/10155899_240333846157972_3108893745639530212_s.jpg",
"link": "https://www.facebook.com/photo.php?fbid=240333846157972&set=a.239581289566561.1073741833.100005440749818&type=1&relevant_count=1",
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/100005440749818/posts/240333912824632"
},
{
"name": "Like",
"link": "https://www.facebook.com/100005440749818/posts/240333912824632"
}
],
"privacy": {
"description": "Public",
"value": "EVERYONE",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"type": "photo",
"status_type": "added_photos",
"object_id": "240333846157972",
"created_time": "2014-04-25T10:33:45+0000",
"updated_time": "2014-04-25T10:33:45+0000",
"likes": {
"data": [
{
"id": "100005440749818",
"name": "Birjesh Sharma"
}
],
"paging": {
"cursors": {
"after": "MTAwMDA1NDQwNzQ5ODE4",
"before": "MTAwMDA1NDQwNzQ5ODE4"
}
}
}
},
and when i am using this graph api in xcode the data show this
Results: {
id = 100005440749818;
posts = {
data = (
{
"created_time" = "2014-04-17T14:13:12+0000";
from = {
id = 100005440749818;
name = "Birjesh Sharma";
};
id = "100005440749818_238353183022705";
link = "https://www.facebook.com/nitin.dhiran.1?fref=nf_fr";
picture = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn2/t1.0-1/c0.9.50.50/p50x50/10262125_697172320343788_6250762651875413687_t.jpg";
privacy = {
value = "";
};
"status_type" = "approved_friend";
story = "Birjesh Sharma is now friends with Nitin Dhiran and 3 other people.";
"story_tags" = {
0 = (
{
id = 100005440749818;
length = 14;
name = "Birjesh Sharma";
offset = 0;
type = user;
}
);
35 = (
{
id = 100001530793389;
length = 12;
name = "Nitin Dhiran";
offset = 35;
type = user;
}
);
52 = (
{
id = 100008058972523;
length = 14;
name = "Hemant Kumar";
offset = 52;
type = user;
},
{
id = 100001307401657;
length = 14;
name = "Chetan Pushpad";
offset = 52;
type = user;
},
{
id = 100002675972915;
length = 14;
name = "Vipin Shukla";
offset = 52;
type = user;
}
);
};
type = link;
"updated_time" = "2014-04-17T14:13:12+0000";
},
{
"created_time" = "2014-03-27T07:21:35+0000";
from = {
id = 100005440749818;
name = "Birjesh Sharma";
};
id = "100005440749818_232528183605205";
privacy = {
value = "";
};
"status_type" = "approved_friend";
story = "Birjesh Sharma is now friends with Ishant Tiwari and Viraj Dongre.";
"story_tags" = {
0 = (
{
id = 100005440749818;
length = 14;
name = "Birjesh Sharma";
offset = 0;
type = user;
}
);
35 = (
{
id = 100000329153640;
length = 13;
name = "Ishant Tiwari";
offset = 35;
type = user;
}
);
53 = (
{
id = 100002123975517;
length = 12;
name = "Viraj Dongre";
offset = 53;
type = user;
}
);
};
type = status;
"updated_time" = "2014-03-27T07:21:35+0000";
}
);
paging = {
next = "https://graph.facebook.com/100005440749818/posts?access_token=CAAUTJQ2n428BAN3p9kiFFMZA7ZBlDO2NTIddfkUNJdbqT32kfbVs8GJaORmJXTF4NnF6RUtIwwp0H0vTzS147lxFF3runTHbupqZBkxbyl73dV5URHwvZA78CqVXWJggaofAy2JfZBf1GCoUQfNCyN0TAJaEnnsLn9ea6d2wLtDAataFtxGyFQJwZBWajQOiIwtidXqliCFV8haorHgfE4ahdbpO5n7oUZD&limit=25&until=1395904894";
previous = "https://graph.facebook.com/100005440749818/posts?access_token=CAAUTJQ2n428BAN3p9kiFFMZA7ZBlDO2NTIddfkUNJdbqT32kfbVs8GJaORmJXTF4NnF6RUtIwwp0H0vTzS147lxFF3runTHbupqZBkxbyl73dV5URHwvZA78CqVXWJggaofAy2JfZBf1GCoUQfNCyN0TAJaEnnsLn9ea6d2wLtDAataFtxGyFQJwZBWajQOiIwtidXqliCFV8haorHgfE4ahdbpO5n7oUZD&limit=25&since=1397743992&__previous=1";
};
};
}
The posts list is divided into several pages, and you only got the first page. To get all the posts, use the URL in results.posts.paging.next.
You can use this FBSDKGraphRequest paging extension to do that for you.