I am using the following code to get the news feed from facebook-
NSString *urlStringFacebook = [NSString stringWithFormat:#"https://graph.facebook.com/v2.2/me/home?format=json&&access_token=%#&&limit=90",[[FBSession activeSession] accessTokenData]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[urlStringFacebook stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
[request setHTTPMethod:#"GET"];
NSHTTPURLResponse *response;
NSError *error;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
I have tried with different limit and different FB version.
Sometimes I get 3-4 feeds sometimes zero. It is happening only from 2 days before that I was getting news feeds.
Please help me.
Thanks
This seems to be a bug.
File a report at https://developers.facebook.com/bugs
Yes, this is a facebook bug. I reported here-
https://developers.facebook.com/bugs/449167695235902
Related
How to get urllink data that are stored in database in iphone sdk ?
Use the following Code may be help you.
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:#"Your URL"]]];
// Perform request and get JSON as a NSData object
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSLog(#"Your Data=%#",response);
id jsonObject = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingAllowFragments error:nil];
I am facing a problem regarding facebook sdk in ios . I made an app that uses facebook login and at the time of login it ask me to allow permission that my app can post on my facebook wall or not. I want to check that permission is allowed by the user or not. How can I check that. Do you have any idea?
Thank you!
Try it :
NSString *theWholeUrl = [NSString stringWithFormat:#"https://graph.facebook.com/me/permissions?access_token=%#",[[FBSession activeSession] accessToken]];
NSLog(#"TheWholeUrl: %#", theWholeUrl);
NSURL *facebookUrl = [NSURL URLWithString:theWholeUrl];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:facebookUrl];
[req setHTTPMethod:#"GET"];
NSURLResponse *response;
NSError *err;
NSData *responseData = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&err];
NSString *content = [NSString stringWithUTF8String:[responseData bytes]];
//NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
SBJSON *json = [SBJSON new];
NSError *error = nil;
NSDictionary * dictionary =[json objectWithString:content error:&error];
The accepted answer uses the Graph API but I presume you are using the native iOS Facebook SDK to make things easier?
If so you can find your issue fully documented by Facebook here. They cover all the different scenarios, including how to handle declined permissions and how to re-ask for permission when you need it.
The right way to do this with the Graph API is to use User.permissions.
https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fpermissions
I have below code for posting data to the web server but it gives me null response, I have multiple data and they are:-
date,
rig,
driller,
offsider-1,
offsider-2,
shift
,
project,
supervisoremail,
geologistemail,
comments,
plants[0][name-id],
plants[0][start-usage],
plants[0][end-usage],
consumables[0][category],
consumables[0][name-id],
consumables[0][used],
consumables[0][code],
consumables[0][description],
I have to post this data and I used this code for posting but it didn't work for me. Please help me out.
NSURL *url=[NSURL URLWithString:#"http://www.mydor.com.au/staff/dor/idorInsert"];
NSString *post =[[NSString alloc]initWithFormat:#"date=15/08/2012&rig=53&driller=207&offsider-1=131&offsider- 2=236&shift=day&project=24&supervisoremail=24&geologistemail=24&comments=&plants[0][name- id]=286&plants[0][start-usage]=1.0&plants[0][end-usage]=0.0"];
NSLog(post);
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:#"%d", [postData length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:url];
[request setHTTPMethod:#"POST"];
[request setValue:postLength forHTTPHeaderField:#"Content-Length"];
[request setValue:#"application/x-www-form-urlencoded" forHTTPHeaderField:#"Content-Type"];
[request setHTTPBody:postData];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]];
NSError *error;
NSURLResponse *response;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSLog(#"here u re");
NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
NSLog(#"here also called");
NSLog(#"%#",data)
Thanks in advance.
Here is an article which demonstrates how to consume .NET Web service using iOS application. You can use the techniques discussed in the article:
http://www.highoncoding.com/Articles/809_Consuming__NET_Web_Services_in_an_iOS_Application.aspx
Almost all the work I do involves .NET with iOS. Have a look here for the network class I wrote and use all the time (AFNetworking based). I prefer to use a regular aspx form instead of an asmx web-service. I do this because I don't want to expose any web-methods to snooping visitors and I use an API key check before returning anything in the aspx form. I can send you an example .NET code (written in VB.NET) if you need me to.
When making the following HTTP POST request:
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:#"POST"];
NSURLResponse *urlResponse = nil;
NSError *error = nil;
// execute
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
if(responseData)
{
//blah
}
I get back a valid response when connected via WiFi, but not when connected over 3G. The responseData object doesn't even get made (0x0) when coming back over 3G.
I get kCFErrorDomainCFNetwork error 303.
The response ought to be 242k of JSON.
Any help would be greatly appreciated.
Thanks.
It seemed that the problem was between the back end system and the mobile networks. Changing the header information to text format only solved the issue.
I am working on an iPhone project which need to connect to the IIS server over HTTPS or SSL protocol. Can anyone tell me how to implement HTTPS connection in iPhone? Any advice would be appreciate.
Thank you in advance.
Ben Copsey's ASIHTTPRequest framework makes it trivially easy to issue web requests over SSL.
Modifying the site's example slightly:
NSURL *url = [NSURL URLWithString:#"https://allseeing-i.com"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request startSynchronous];
NSError *error = [request error];
if (!error) {
NSString *response = [request responseString];
NSLog (#"%#", response);
}
Just use NSURLConnection with an NSURLRequest pointing to an NUSUL with https protocol, just like that:
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:#"https://mySecureServer.net"]];
NSURLResponse *response = nil;
NSError *error = nil;
NSData *result = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if (!error) {
//do something with response & data
}
But I suggest you have a look at the documentation of the URL loading system in Cocoa.
Jason don't forget to implement the connection:canAuthenticateAgainsProtectionSpace and connection:didReceiveAuthenticationChallenge to make sure you're handling the challenges for the Server authentication and Client Authentication:
check out this post that will help you with this https://devforums.apple.com/message/143091#143091
You probably don't have a public certificate. Can you access the https resource with firefox/safari/chrome without an error? if not - that's the problem, not your code.