retrireving albums images from Facebook using graph api ios - ios

i am trying facebook albums integration, used me/albums methods its showing this graph api query: I am getting json format correctly but the thing is i want to retrieve album images one by one and display it in grid view ...please anybody suggest some code or idea...
Results: {
data = (
{
"can_upload" = 1;
count = 2;
"cover_photo" = 1404379296458611;
"created_time" = "2013-10-04T11:35:21+0000";
from = {
id = 100006596624401;
name = "sample";
};
id = 1404366983126509;
link = "https://www.facebook.com/album.php?fbid=1404366983126509&id=100006596624401&aid=1073741827";
name = "Photos";
privacy = custom;
type = app;
"updated_time" = "2013-10-09T07:41:48+0000";
},
{
"can_upload" = 0;
"created_time" = "2013-10-08T10:55:52+0000";
from = {
id = 100006596624401;
name = "sample";
};
id = 1406014439628430;
link = "https://www.facebook.com/album.php?fbid=1406014439628430&id=100006596624401&aid=1073741829";
name = "he Photos";
privacy = custom;
type = app;
"updated_time" = "2013-10-08T11:33:49+0000";
},
{
"can_upload" = 0;
count = 1;
"cover_photo" = 1405547679675106;
"created_time" = "2013-10-07T06:21:36+0000";
from = {
id = 100006596624401;
name = "sample";
};
id = 1405547666341774;
link = "https://www.facebook.com/album.php?fbid=1405547666341774&id=100006596624401&aid=1073741828";
name = test;
privacy = everyone;
type = normal;
"updated_time" = "2013-10-07T06:21:47+0000";
},
{
"can_upload" = 0;
"created_time" = "2013-09-25T05:30:31+0000";
from = {
id = 100006596624401;
name = "sample";
};
id = 1399900213573186;
link = "https://www.facebook.com/album.php?fbid=1399900213573186&id=100006596624401&aid=1073741825";
name = "iOS Photos";
privacy = everyone;
type = app;
"updated_time" = "2013-09-25T06:26:13+0000";
}
);
paging = {
cursors = {
after = "MTM5OTkwMDIxMzU3MzE4Ng==";
before = "MTQwNDM2Njk4MzEyNjUwOQ==";
};
};

Related

How to merge 2 Arrays by comparing two different objects having same values ?

I have 2 Arrays named "onGoingBookings" and "sortedMSArray" . I want to inject / merge sortedMSArray (status key only) to onGoingBooings Array (main Array) when both booking id values are same.
Response of OngoingBookings
{
addrLine1 = "Al Thanyah Fifth, Dubai, United Arab Emirates";
addrLine2 = " ";
amount = "";
apntDate = "2017-12-11";
apntDt = "2017-12-11 11:48:18";
apntTime = "11:48 am";
apptLat = "25.071571350098";
apptLong = "55.14294052124";
bid = 374;
bookType = 1;
cancelAmount = 30;
"cancel_reason" = "";
"cat_name" = "Car Wash";
"dispute_msg" = "";
disputed = "";
dt = 20171211114818;
email = "dev#ios.com";
fdata = {
};
fname = Apple;
lname = Mob;
notes = "";
pPic = "https://s3.amazonaws.com/iserve/ProfileImages/dev#ios.com2017-11-2711:34:26.jpg";
phone = 561462146;
pid = 48;
"star_rating" = 0;
statCode = 6;
status = "Job started.";
},
{
addrLine1 = "Al Thanyah Fifth, Dubai, United Arab Emirates";
addrLine2 = " ";
amount = "";
apntDate = "2017-12-06";
apntDt = "2017-12-06 19:29:14";
apntTime = "07:29 pm";
apptLat = "25.071369171143";
apptLong = "55.143840789795";
bid = 354;
bookType = 2;
cancelAmount = 50;
"cancel_reason" = "";
"cat_name" = Plumbing;
"dispute_msg" = "";
disputed = "";
dt = 20171206192914;
email = "";
fdata = {
};
fname = "";
lname = "";
notes = "";
pPic = "";
phone = "";
pid = "";
"star_rating" = 0;
statCode = 1;
status = "Job Pending";
},
{
addrLine1 = "Al Thanyah Fifth, Dubai, United Arab Emirates";
addrLine2 = " ";
amount = "";
apntDate = "2017-12-06";
apntDt = "2017-12-06 19:24:12";
apntTime = "07:24 pm";
apptLat = "25.071369171143";
apptLong = "55.143840789795";
bid = 353;
bookType = 1;
cancelAmount = 30;
"cancel_reason" = "";
"cat_name" = "Car Wash";
"dispute_msg" = "";
disputed = "";
dt = 20171206192412;
email = "";
fdata = {
};
fname = "";
lname = "";
notes = "";
pPic = "";
phone = "";
pid = "";
"star_rating" = 0;
statCode = 1;
status = "Job Pending";
},
Response of sortedMSArray
{
bookingid = 325;
status = 1;
},
{
bookingid = 333;
status = 3;
},
{
bookingid = 374;
status = 3;
}
I need Following Solution
Step 1 - compare both array by using #"bid"(ongoingbookings) and #"bookingid"(sortedMSArray)
Step 2 - merge the status key when both booking ids are same.
Please post a code snipped according to my code and response.
Reference Codes
if(requestType == RequestTypeGetAllApptDetails)
{
if(pageIndex == 0)
{
pastBookings = [[NSMutableArray alloc]init];
onGoingBookings = response[#"ongoing_appts"];
NSLog(#"CHECKINGFAST%#",onGoingBookings);
}
[pastBookings addObjectsFromArray:response[#"past_appts"]];
self.tableView.backgroundView = self.messageView;
[self.tableView reloadData];
}
else if(requestType == RequestTypeGetReportMaterialStatus)
{ // NSArray *custStatusTempArray = response;
customerStatusArray = response;
customerstatusDict = response[#"customerstatus"];
NSLog(#"CUSTOMERSTATUSARRAY %#", customerStatusArray);
NSLog(#"CUSTOMERSTATUSDICT %#", customerstatusDict);
if(customerStatusArray == nil || [customerStatusArray count]==0)
{
NSLog(#"NO MATERIAL ACCEPTED");
}
else
{
custStatusFilteredArray = [NSMutableArray array];
if([customerstatusDict isKindOfClass:[NSDictionary class]])
{
NSDictionary *dict = (NSDictionary *)customerstatusDict;
[dict enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
[custStatusFilteredArray addObject:obj];
NSLog(#"FILTEREDARRAY%#",custStatusFilteredArray);
}];
}
materialStatusStringArray = [custStatusFilteredArray copy];
NSLog(#"materialStatusStringarray%#",materialStatusStringArray);
//sorting the materialstatus string array
NSSortDescriptor* sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:#"bookingid" ascending:NO];
sortedMSArray = [materialStatusStringArray sortedArrayUsingDescriptors:#[sortDescriptor]];
NSLog(#"Sorted Array Response -%#", sortedMSArray);

Upload image in imageview inside collectionView using sdwebimage

I have to show image in imageView using SDWebImage
Here is my code:
NSString *string2 = [[dataArray objectAtIndex:indexPath.row ]valueForKey:#"logo"];
[imagev sd_setImageWithURL:[NSURL URLWithString:#"http://dev-demo.info.bh-in-15.webhostbox.net/dv/nationalblack/upload/post/"]
placeholderImage:[UIImage imageNamed:string2]
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
imagev.image = image;
}];
I am not getting any image inside ImageView
data I am getting from the server is
data array (
{
address = brisbane;
amount = 0;
"business_phone" = 9990688436;
catid = 0;
catname = "";
city = delhi;
contactperson = "Gautam Kumar";
country = Australia;
createdon = 1464935578;
email = "gautam.kumar#eyeforweb.com";
expirydays = 366;
expirymail = 0;
"fb_address" = "";
id = 78;
"inst_address" = "";
isexpired = 0;
isfeatured = 0;
lat = "-33.7961";
"link_address" = "";
lng = "151.146";
logo = "";
longdesc = "xyz ";
mobileno = "";
officephone = "";
ondedaysmail = 0;
"package_name" = 0;
paidamount1 = 0;
paydate1 = 0;
paystatus1 = 1;
"prod_name" = 13;
"pt_address" = "";
sevendaysmail = 0;
shortdesc = hello123;
state = "New South Wales";
status = 1;
tags = "";
"tb_address" = "";
title = aayush;
transcationid1 = "";
"tw_address" = "";
userid = 5;
username = "Gautam Kumar";
"var_name" = 56;
"web_address" = "";
},
{
address = "Address 1";
amount = 0;
"business_phone" = 9990688436;
catid = 0;
catname = "";
city = ABD;
contactperson = "Gautam Kumar";
country = Australia;
createdon = 1464158696;
email = "gautam.kumar#eyeforweb.com";
expirydays = 357;
expirymail = 0;
"fb_address" = "";
id = 75;
"inst_address" = "";
isexpired = 0;
isfeatured = 0;
lat = "-37.488";
"link_address" = "";
lng = "144.592";
logo = "appflowchart_4c1.gif";
longdesc = "This is short Description.";
mobileno = "";
officephone = "";
ondedaysmail = 0;
"package_name" = 0;
paidamount1 = 0;
paydate1 = 0;
paystatus1 = 1;
"prod_name" = 3;
"pt_address" = "";
sevendaysmail = 0;
shortdesc = "This is short Description.";
state = Gisborne;
status = 1;
tags = "";
"tb_address" = "";
title = Business1;
transcationid1 = "";
"tw_address" = "";
userid = 5;
username = "Gautam Kumar";
"var_name" = 0;
"web_address" = "";
},
{
address = "Paschim Vihar ,Delhi";
amount = 0;
"business_phone" = 9990688436;
catid = 0;
catname = "";
city = "New Delhi";
contactperson = "Gautam Kumar";
country = Australia;
createdon = 1464065014;
email = "gautam.kumar#eyeforweb.com";
expirydays = 356;
expirymail = 0;
"fb_address" = Facebook;
id = 72;
"inst_address" = Instagram;
isexpired = 0;
isfeatured = 0;
lat = "-37.488";
"link_address" = linked;
lng = "144.592";
logo = "Screenshot_(1)_61b.png";
longdesc = sdfsdfdsf;
mobileno = "";
officephone = "";
ondedaysmail = 0;
"package_name" = 0;
paidamount1 = 0;
paydate1 = 0;
paystatus1 = 1;
"prod_name" = 3;
"pt_address" = Pinsta;
sevendaysmail = 0;
shortdesc = fffsdf;
state = Gisborne;
status = 1;
tags = "";
"tb_address" = Tumbler;
title = "First business";
transcationid1 = "";
"tw_address" = Twitter;
userid = 5;
username = "Gautam Kumar";
"var_name" = 2;
"web_address" = Website;
},
{
address = Laxminagar;
amount = 0;
"business_phone" = 9990688436;
catid = 0;
catname = "";
city = "New Delhi1";
contactperson = "Gautam Kumar";
country = Australia;
createdon = 1463651418;
email = "gautam.kumar#eyeforweb.com";
expirydays = 7;
expirymail = 0;
"fb_address" = Facebook;
id = 61;
"inst_address" = Instagram;
isexpired = 0;
isfeatured = 0;
lat = "28.6433";
"link_address" = linked;
lng = "77.0363";
logo = "Screenshot_(1)_0ba.png";
longdesc = asxasxasx;
mobileno = "";
officephone = "";
ondedaysmail = 0;
"package_name" = 0;
paidamount1 = 0;
paydate1 = 0;
paystatus1 = 1;
"prod_name" = 3;
"pt_address" = Pinsta;
sevendaysmail = 0;
shortdesc = xasxasx;
state = Victoria;
status = 1;
tags = "";
"tb_address" = Tumbler;
title = "Testing by Gautam";
transcationid1 = 1111111111111;
"tw_address" = Twitter;
userid = 5;
username = "Gautam Kumar";
"var_name" = 2;
"web_address" = Website;
}
)
Aayush Katiyar,
From iOS 8 onwards you are not supposed to use http you should make use of secure channels https. In case you dont have one consider adding these to your plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
All your image download api is making use of http:// I guess that might be the issue here
Finally change the way you load the image as
[imagev sd_setImageWithURL:[NSURL URLWithString: [NSString stringWithFormat:#"%#/%#",#"http://dev-demo.info.bh-in-15.webhostbox.net/dv/nationalblack/upload/post/", string2]]
placeholderImage:[UIImage imageNamed:#"Some_Placeholder_Image"]
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
imagev.image = image;
}];
Just use like this,
[cell.myImageView sd_setImageWithURL:finalImageUrl];
finalImageUrl is your final url for download image.
No need to use method with completion handlerl. it is for different task.

Manipulating NSDictionary data

I've managed to export the below data, multiplied by several hundred, into an NSDictionary. I now need to build out a way to put this data into Tinder style app. Can anyone advise how I can get my app to pull out the data against Key "Title" for various indexes. Currently it pulls out 45 records of data containing that one Title as there are 45 keys in my data set.
{
AttachmentFiles = {
"__deferred" = {
uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/AttachmentFiles";
};
};
Attachments = 0;
AuthorId = 22;
AverageRating = "<null>";
BestAnswerId = "<null>";
Body = "We need to think xyz";
CategoriesLookupId = 16;
Community = "<null>";
ContentType = {
"__deferred" = {
uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/ContentType";
};
};
ContentTypeId = 0x01200200C5BB1FEE2601B9439CD527C288D85A7B;
Created = "2014-03-21T08:37:33Z";
DescendantLikesCount = 8;
DescendantRatingsCount = "<null>";
DiscussionLastUpdated = "2014-06-19T12:57:58Z";
EditorId = 96;
EmailSender = "<null>";
FieldValuesAsHtml = {
"__deferred" = {
uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/FieldValuesAsHtml";
};
};
FieldValuesAsText = {
"__deferred" = {
uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/FieldValuesAsText";
};
};
FieldValuesForEdit = {
"__deferred" = {
uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/FieldValuesForEdit";
};
};
File = {
"__deferred" = {
uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/File";
};
};
FileSystemObjectType = 1;
FilterCategory = "<null>";
FirstUniqueAncestorSecurableObject = {
"__deferred" = {
uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/FirstUniqueAncestorSecurableObject";
};
};
Folder = {
"__deferred" = {
uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/Folder";
};
};
GUID = "28144fd4-84b0-434b-9e99-01d939e6a773";
Has20likes = "<null>";
ID = 3;
Id = 3;
IsFeatured = 0;
IsIdeaCreated = "<null>";
IsQuestion = 0;
LastReplyById = 49;
LikesCount = 5;
MemberLookupId = 7;
Modified = "2015-03-11T15:25:20Z";
"OData__UIVersionString" = "2.0";
ParentItemEditorId = "<null>";
ParentItemID = "<null>";
ParentList = {
"__deferred" = {
uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/ParentList";
};
};
Popularity = "7.23632608186099";
RatingCount = "<null>";
RoleAssignments = {
"__deferred" = {
uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)/RoleAssignments";
};
};
StepChangePillar = "<null>";
Title = "JIRA Governance";
"__metadata" = {
etag = "\"14\"";
id = "Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)";
type = "SP.Data.Community_x0020_DiscussionListItem";
uri = "https://xxxxxxx/_api/Web/Lists(guid'1594ea5e-0ca7-4de3-81aa-4082bde336a4')/Items(3)";
};
},
Thanks
You should have an array of dictionaries correct?
If so this should work:
NSInteger index = 0; //You can set this to the current page of your scroll view
NSArray * items = /* YOUR ARRAY OF DICTIONARIES */;
NSDictionary * dict = [items objectAtIndex:index];
NSString * title = [dict objectForKey:#"Title"];
You might also consider making a subclass of NSObject and building in a parser for your dictionary so you can access the variables with strong types.

how to retrieve-albums-images-from-facebook-using-graph-api-ios

I am getting json format correctly but the thing is i want to retrieve album images one by one and display it in grid view ...please anybody suggest some code or idea...
Pl suggest me how to get album id for each photos in albums
Results: {
data = (
{
"can_upload" = 1;
count = 2;
"cover_photo" = 1404379296458611;
"created_time" = "2013-10-04T11:35:21+0000";
from = {
id = 100006596624401;
name = "sample";
};
id = 1404366983126509;
link = "https://www.facebook.com/album.php?fbid=1404366983126509&id=100006596624401&aid=1073741827";
name = "Photos";
privacy = custom;
type = app;
"updated_time" = "2013-10-09T07:41:48+0000";
},
{
"can_upload" = 0;
"created_time" = "2013-10-08T10:55:52+0000";
from = {
id = 100006596624401;
name = "sample";
};
id = 1406014439628430;
link = "https://www.facebook.com/album.php?fbid=1406014439628430&id=100006596624401&aid=1073741829";
name = "he Photos";
privacy = custom;
type = app;
"updated_time" = "2013-10-08T11:33:49+0000";
},
{
"can_upload" = 0;
count = 1;
"cover_photo" = 1405547679675106;
"created_time" = "2013-10-07T06:21:36+0000";
from = {
id = 100006596624401;
name = "sample";
};
id = 1405547666341774;
link = "https://www.facebook.com/album.php?fbid=1405547666341774&id=100006596624401&aid=1073741828";
name = test;
privacy = everyone;
type = normal;
"updated_time" = "2013-10-07T06:21:47+0000";
},
{
"can_upload" = 0;
"created_time" = "2013-09-25T05:30:31+0000";
from = {
id = 100006596624401;
name = "sample";
};
id = 1399900213573186;
link = "https://www.facebook.com/album.php?fbid=1399900213573186&id=100006596624401&aid=1073741825";
name = "iOS Photos";
privacy = everyone;
type = app;
"updated_time" = "2013-09-25T06:26:13+0000";
}
);
paging = {
cursors = {
after = "MTM5OTkwMDIxMzU3MzE4Ng==";
before = "MTQwNDM2Njk4MzEyNjUwOQ==";
};
};
Try this
FbGraphResponse *fb_graph_response = [fbGraph doGraphGet:#"me/albums" withGetVars:nil];
NSDictionary *albums = (NSDictionary *)[fb_graph_response.htmlResponse JSONValue];
NSMutableArray * albumids = [[NSMutableArray alloc] init];
albumids = [albums objectForKey:#"data"];
for(int i =0; i< [albumids count]; i++)
{
NSDictionary *dictuser = (NSDictionary *)[albumids objectAtIndex:i];
[album addObject:[dictuser objectForKey:#"id"]];
[albumname addObject:[dictuser objectForKey:#"name"]];
}
Swift 4.0 Version
let request = FBSDKGraphRequest.init(graphPath: "/me/albums", parameters: ["fields": "photo_count,name,id" ], httpMethod: "GET")
request?.start(completionHandler: { (connection, result, error) in
})
In case you want to get picture of Album then use this
"fields": "photo_count,name,id, picture"
Facebook also have a Graph Api Explorer which is very helpful

How to get all the photos when user uploads 2 or more in Facebook for iOS

{
comments = {
count = 0;
};
"created_time" = "2013-01-23T06:12:43+0000";
from = {
id = 1171029418;
name = "Ilse Anhy";
};
icon = "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif";
id = "1171029418_10200426347839190";
link = "https://www.facebook.com/photo.php?fbid=10200426378279951&set=a.3604514069432.2168112.1171029418&type=1&relevant_count=2";
"object_id" = 10200426378279951;
picture = "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/265145_10200426378279951_1504367216_s.jpg";
privacy = {
value = "";
};
"status_type" = "added_photos";
story = "Ilse Anhy added 2 new photos.";
"story_tags" = {
0 = (
{
id = 1171029418;
length = 9;
name = "Ilse Anhy";
offset = 0;
type = user;
}
);
};
type = photo;
"updated_time" = "2013-01-23T06:12:43+0000";
}
In the "story" object it says "Ilse Anhy added 2 new photos."
In the "picture" object it only gives a reference to a single photo. How would I be able to retrieve the other photo?

Resources