I have sent facebook request. Its working fine, but I am getting request(notification) only in iPhone facebook App, not in Facebook web application. I want both Facebook native app and web application to receive notification. How can I do that?
#pragma Sending Facebook app request
- (NSDictionary*)parseURLParams:(NSString *)query {
NSArray *pairs = [query componentsSeparatedByString:#"&"];
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
for (NSString *pair in pairs) {
NSArray *kv = [pair componentsSeparatedByString:#"="];
NSString *val =
[[kv objectAtIndex:1]
stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[params setObject:val forKey:[kv objectAtIndex:0]];
}
return params;
}
- (void)sendRequest {
NSError *error;
NSData *jsonData = [NSJSONSerialization
dataWithJSONObject:#{
#"social_karma": #"5",
#"badge_of_awesomeness": #"1"}
options:0
error:&error];
if (!jsonData) {
NSLog(#"JSON error: %#", error);
return;
}
NSString *giftStr = [[NSString alloc]
initWithData:jsonData
encoding:NSUTF8StringEncoding];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
giftStr, #"data",
nil];
// Display the requests dialog
[FBWebDialogs
presentRequestsDialogModallyWithSession:nil
message:#"Learn how to make your iOS apps social."
title:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Error launching the dialog or sending the request.
NSLog(#"Error sending request.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User clicked the "x" icon
NSLog(#"User canceled request.");
} else {
// Handle the send request callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:#"request"]) {
// User clicked the Cancel button
NSLog(#"User canceled request.");
} else {
// User clicked the Send button
NSString *requestID = [urlParams valueForKey:#"request"];
NSLog(#"Request ID: %#", requestID);
}
}
}
}];
}
- (void)sendRequestClicked {
// Filter and only show friends using iOS
[self requestFriendsUsingDevice:#"iOS"];
}
- (void)sendRequest:(NSArray *) targeted {
NSError *error;
NSData *jsonData = [NSJSONSerialization
dataWithJSONObject:#{
#"social_karma": #"5",
#"badge_of_awesomeness": #"1"}
options:0
error:&error];
if (!jsonData) {
NSLog(#"JSON error: %#", error);
return;
}
NSString *giftStr = [[NSString alloc]
initWithData:jsonData
encoding:NSUTF8StringEncoding];
NSMutableDictionary* params =
[NSMutableDictionary dictionaryWithObjectsAndKeys:giftStr, #"data",
nil];
// Filter and only show targeted friends
if (targeted != nil && [targeted count] > 0) {
NSString *selectIDsStr = [targeted componentsJoinedByString:#","];
[params setObject:selectIDsStr forKey:#"suggestions"];
}
// Display the requests dialog
[FBWebDialogs
presentRequestsDialogModallyWithSession:nil
message:#"Learn how to make your iOS apps social."
title:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Error launching the dialog or sending request.
NSLog(#"Error sending request.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User clicked the "x" icon
NSLog(#"User canceled request.");
} else {
// Handle the send request callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:#"request"]) {
// User clicked the Cancel button
NSLog(#"User canceled request.");
} else {
// User clicked the Send button
NSString *requestID = [urlParams valueForKey:#"request"];
NSLog(#"Request ID: %#", requestID);
}
}
}
}];
}
- (void) requestFriendsUsingDevice:(NSString *)device {
NSMutableArray *deviceFilteredFriends = [[NSMutableArray alloc] init];
[FBRequestConnection startWithGraphPath:#"me/friends"
parameters:[NSDictionary
dictionaryWithObjectsAndKeys:
#"id,devices", #"fields",
nil]
HTTPMethod:nil
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (!error) {
// Get the result
NSArray *resultData = [result objectForKey:#"data"];
// Check we have data
if ([resultData count] > 0) {
// Loop through the friends returned
for (NSDictionary *friendObject in resultData) {
// Check if devices info available
if ([friendObject objectForKey:#"devices"]) {
NSArray *deviceData = [friendObject
objectForKey:#"devices"];
// Loop through list of devices
for (NSDictionary *deviceObject in deviceData) {
// Check if there is a device match
if ([device isEqualToString:
[deviceObject objectForKey:#"os"]]) {
// If there is a match, add it to the list
[deviceFilteredFriends addObject:
[friendObject objectForKey:#"id"]];
break;
}
}
}
}
}
}
// Send request
[self sendRequest:deviceFilteredFriends];
}];
}
You can only get notifications on Facebook web application if your app has a Facebook Canvas app implemented.
The invitable_friends API is only available for games that have a
Facebook Canvas app implementation using version 2.0 of the Graph API.
Check here the full documentation
Canvas is a frame in which to put your app or game directly on
Facebook.com on desktops and laptops.
Details about Canvas
Note: In the documentation you will find "your game", they mean "your game or your app".
Related
I am getting an issue while posting a feed on Facebook using Facebook sdk in ios7.
I have copied the code from Facebook samples provided on Github. But whenever I tried to post on Facebook, a message appears as "An error occurred. Please try again later". And then I have to close the web view.
Please find the code below:
NSMutableDictionary *params123 = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Roasted pumpkin seeds", #"name",
#"Healthy snack.", #"caption",
#"Crunchy pumpkin seeds roasted in butter and lightly salted.", #"description",
#"http://example.com/roasted_pumpkin_seeds", #"link",
#"http://i.imgur.com/g3Qc1HN.png", #"picture",
nil];
// Show the feed dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params123
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"Error publishing story: %#", error.description);
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User cancelled.
NSLog(#"User cancelled.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:#"post_id"]) {
// User cancelled.
NSLog(#"User cancelled.");
} else {
// User clicked the Share button
NSString *result = [NSString stringWithFormat: #"Posted story, id: %#", [urlParams valueForKey:#"post_id"]];
NSLog(#"result %#", result);
}
}
}
}];
}
Note: I am using the updated version of Facebook sdk for iOS 7
Why do you use a webdialog ?
Here is what I use
NSArray *urlsArray = [NSArray arrayWithObjects:#"myurl1", nil];
NSURL *imageURL = [NSURL URLWithString:#"http://url/to/image.png"];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage *image = [UIImage imageWithData:imageData];
NSArray *imagesArray = [NSArray arrayWithObjects:image, nil];
[FBDialogs presentOSIntegratedShareDialogModallyFrom:self
session:nil
initialText:#"My message for facebook"
images:imagesArray
urls:urlsArray
handler:^(FBOSIntegratedShareDialogResult result, NSError *error) {
NSLog(#"Result : %u", result);
if (error != nil) {
NSLog(#"Error : %#", [error localizedDescription]);
}
}];
I am trying to fetch user details but am currently unable to fetch images.This is the error I am getting:
{
error = {
code = 2500;
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
};
}
This is my code:
if(!self.store)
{
ACAccountStore *store1 = [[ACAccountStore alloc] init];
self.store=store1;
[store1 release];
}
ACAccountType *fbAccountType =
[store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSArray * permissions = #[#"read_stream", #"publish_stream",#"email", #"user_birthday",#"publish_actions",#"user_photos"];
NSDictionary * dict = #{ACFacebookAppIdKey : #"my_key", ACFacebookPermissionsKey : permissions, ACFacebookAudienceKey : ACFacebookAudienceOnlyMe};
// Request permission from the user to access the available Twitter accounts
[store requestAccessToAccountsWithType:fbAccountType options:dict completion:^(BOOL granted, NSError *error) {
__block NSString * statusText = nil;
if (granted) {
statusText = #"Logged in";
NSArray * accounts = [store accountsWithAccountType:fbAccountType];
store = [accounts lastObject];
account = [accounts objectAtIndex:0];
NSLog(#"account is: %#", account);
NSURL *requestURL = [NSURL URLWithString:#"https://graph.facebook.com/me?fields=picture"];
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:requestURL
parameters:nil];
request.account = account;
[request performRequestWithHandler:^(NSData *data,
NSHTTPURLResponse *response,
NSError *error) {
if(!error){
NSDictionary *list =[NSJSONSerialization JSONObjectWithData:data
options:kNilOptions error:&error];
NSLog(#"Dictionary contains: %#", list );
}
else{
//handle error gracefully
}
}];
}
If I use https://graph.facebook.com/me as url then it works fine. But I need the profile pic as well. What to do?
"fields" is a parameter, not a part of the URL itself. This works:
SLRequest *videoLimitsRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:[NSURL URLWithString:#"https://graph.facebook.com/me"]
parameters:#{#"fields": #"video_upload_limits"}];
FYI, token is added automatically when you attach account to the SLRequest.
you can run fql with accesstoken like this
https://graph.facebook.com/fql?q=SELECT name from user where uid = YourFAcebookID&access_token=ACCESSTOKEN
This will work for you.
This is a bit old but I forgot to answer then.
From FB api 3.2 onwards everything is managed within the api, for bot iOS 5 and 6 native login. Here is what I did:
FBRequestConnection *newConnection = [[FBRequestConnection alloc] init];
FBRequest *request = [FBRequest requestWithGraphPath:#"me/albums" parameters:nil HTTPMethod:#"GET"];
FBRequestHandler handler =
^(FBRequestConnection *connection, id result, NSError *error)
{
if(!error)
{
NSDictionary *list =(NSDictionary*)result;
int flag = 0;
for (int index = 0; index < [[list objectForKey:#"data"] count];index++)
{
if ([[[[list objectForKey:#"data"] objectAtIndex:index] objectForKey:#"name"] isEqualToString:#"Profile Pictures"])
{
[self fetchAlbumImages:[[[list objectForKey:#"data"] objectAtIndex:index] objectForKey:#"id"]];
flag = 1;
}
}
if (flag == 0)
{
[self fetchAlbumImages:#"No Album"];
}
}
else
{
}
};
[newConnection addRequest:request completionHandler:handler];
//[self.requestConnection cancel];
[newConnection start];
[newConnection release];
}
- (void) fetchAlbumImages:(NSString*)albumId
{
if ([albumId isEqualToString:#"No Album"])
{
NSMutableArray *albumArray = [[NSMutableArray alloc]init];
[self performSelectorOnMainThread:#selector(sendRegistrationRequest:) withObject:albumArray waitUntilDone:YES];
[albumArray release];
}
else
{
FBRequestConnection *newConnection = [[FBRequestConnection alloc] init];
FBRequest *request = [FBRequest requestWithGraphPath:[NSString stringWithFormat:#"%#/photos",albumId] parameters:nil HTTPMethod:#"GET"];
FBRequestHandler handler =
^(FBRequestConnection *connection, id result, NSError *error)
{
if(!error)
{
NSDictionary *list =(NSDictionary*)result;
NSMutableArray *albumArray = [[NSMutableArray alloc]init];
for (int index = 0; index < ([[list objectForKey:#"data"] count]<10?[[list objectForKey:#"data"] count]:10);index++)
{
[albumArray addObject:[[[list objectForKey:#"data"] objectAtIndex:index] objectForKey:#"source"]];
}
[self performSelectorOnMainThread:#selector(sendRegistrationRequest:) withObject:albumArray waitUntilDone:YES];
}
else
{
}
};
[newConnection addRequest:request completionHandler:handler];
//[self.requestConnection cancel];
self.requestConnection = newConnection;
[newConnection start];
[newConnection release];
}
}
I am trying to tag some of my friends in my wall post and I am sending the following parameters but this posts to my wall the FB ids I provide do not get attached to the post...
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Test 2 ",#"message",
#"100004311843201 , 1039844409", #"to",
#"http://www.google.com", #"link",
#"Test", #"name",
nil];
[self.appDelegate.facebook requestWithGraphPath:#"me/feed" andParams:params andHttpMethod:#"POST" andDelegate:self];
Any help is appreciated...
To tag a friend in ur fb status ..you need "facebook id" of your friend by using FBFriendPickerViewController and "place id" using FBPlacePickerViewController.
Following code will help you.
NSString *apiPath = nil;
apiPath = #"me/feed";
if(![self.selectedPlaceID isEqualToString:#""]) {
[params setObject:_selectedPlaceID forKey:#"place"];
}
NSString *tag = nil;
if(mSelectedFriends != nil){
for (NSDictionary *user in mSelectedFriends) {
tag = [[NSString alloc] initWithFormat:#"%#",[user objectForKey:#"id"] ];
[tags addObject:tag];
}
NSString *friendIdsSeparation=[tags componentsJoinedByString:#","];
NSString *friendIds = [[NSString alloc] initWithFormat:#"[%#]",friendIdsSeparation ];
[params setObject:friendIds forKey:#"tags"];
}
FBRequest *request = [[[FBRequest alloc] initWithSession:_fbSession graphPath:apiPath parameters:params HTTPMethod:#"POST"] autorelease];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
[SVProgressHUD dismiss];
if (error) {
NSLog(#"Error ===== %#",error.description);
if (_delegate != nil) {
[_delegate facebookConnectFail:error requestType:FBRequestTypePostOnWall];
}else{
NSLog(#"Error ===== %#",error.description);
}
}else{
if (_delegate != nil) {
[_delegate faceboookConnectSuccess:self requestType:FBRequestTypePostOnWall];
}
}
I am trying to build simple prototype where I post some text to my facebook account. I have read the ios 6 facebook integration documentation and came up with following code. Everything seems to work fine until I hit the last block where I create SLRequest object in method postTextToFacebook and try to execute performRequestWithHandler with handler block. Control never does inside the handler block. I am assuming that performRequestWithHandler call is not successful in this case. Any one have done with successfully? Here is code for your reference.
#import <Social/Social.h>
#import "ViewController.h"
#implementation ViewController
#synthesize facebookAccount;
#synthesize accountStore;
#synthesize textToPost;
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
-(IBAction) postToFacebook:(id)sender
{
self.statusLabel.text = #"Logging in ...";
if(self.accountStore == nil)
{
self.accountStore = [[ACAccountStore alloc] init];
}
ACAccountType *facebookAccountType = [self.accountStore enter code hereaccountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSMutableDictionary *myOptions = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"172197712918906", ACFacebookAppIdKey,
[NSArray arrayWithObjects:#"email", #"user_about_me", #"user_likes", nil], ACFacebookPermissionsKey, ACFacebookAudienceFriends, ACFacebookAudienceKey, nil];
[self.accountStore requestAccessToAccountsWithType:facebookAccountType options:myOptions completion:^(BOOL granted, NSError *error){
__block NSString *statusText;
if(granted)
{
NSArray *accounts = [self.accountStore accountsWithAccountType:facebookAccountType];
self.facebookAccount = [accounts lastObject];
[myOptions setObject:[NSArray arrayWithObjects:#"publish_stream", nil] forKey:ACFacebookPermissionsKey];
[self.accountStore requestAccessToAccountsWithType:facebookAccountType options:myOptions completion:^(BOOL granted, NSError *error) {
__block NSString *statusText1;
if(granted && error == nil)
{
NSArray *accounts = [self.accountStore accountsWithAccountType:facebookAccountType];
self.facebookAccount = [accounts lastObject];
[self postTextToFacebook];
statusText1 = #"Text Posted.";
}
else{
statusText1 = #"Publish Failed.";
}
dispatch_async(dispatch_get_main_queue(), ^{
self.statusLabel.text = statusText1;
});
}];
}
else{
statusText = #"Login Failed.";
NSLog(#"Error = %#",error);
}
}];
}
-(void) postTextToFacebook
{
NSDictionary *parameters = #{#"message":self.textToPost.text};
NSURL *feedURL = [NSURL URLWithString:#"https://graphs.facebook.com/me/feed"];
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodPOST URL:feedURL parameters:parameters];
request.account = self.facebookAccount;
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSLog(#"Facebook request received, status code %d", urlResponse.statusCode);
NSString *response = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(#"Response data: %#", response);
//handle errors
if(error == nil)
{
dispatch_async(dispatch_get_main_queue(), ^{
self.statusLabel.text = #"text posted to facebook";
});
}
}];
}
#end
Your url should be
https://graph.facebook.com/me/feed
instead of
https://graphs.facebook.com/me/feed
I was having a same issue and got an NSURLErrorDomain -1003 error on it.
I have a problem with implementing Facebook posting on wall in my iPhone application.
I installed SDK and linked framework
login is working fine. here's the code:
-(IBAction)loginButtonPressed:(id)sender
{
NSLog(#"loginButtonPressed: called");
AppDelegate *appdel=[[UIApplication sharedApplication] delegate];
appdel.facebookSession=[[FBSession alloc] init];
[appdel.facebookSession openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error)
{
//
}];
}
But I have a problem with posting message on user's wall. Here's the code:
-(IBAction)likeButtonPressed:(id)sender
{
NSLog(#"likeButtonPressed: called");
// Post a status update to the user's feedm via the Graph API, and display an alert view
// with the results or an error.
NSString *message = #"test message";
NSDictionary *params = [NSDictionary dictionaryWithObject:message forKey:#"message"];
// use the "startWith" helper static on FBRequest to both create and start a request, with
// a specified completion handler.
[FBRequest startWithGraphPath:#"me/feed"
parameters:params
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
[self showAlert:message result:result error:error];
}];
}
Help me please. What's wrong with my code? Or should I add some permissions to login request?
this code worked for me.
First we must
#import <FBiOSSDK/FacebookSDK.h>
then
#property (strong, nonatomic) FBRequestConnection *requestConnection;
and of course do not forget to synthesize:
#synthesize requestConnection;
the code itself:
-(IBAction)likeButtonPressed:(id)sender
{
NSLog(#"likeButtonPressed: called");
// FBSample logic
// Check to see whether we have already opened a session.
if (FBSession.activeSession.isOpen)
{
// login is integrated with the send button -- so if open, we send
[self postOnWall];
}
else
{
[FBSession sessionOpenWithPermissions:[NSArray arrayWithObjects:#"publish_stream", nil]
completionHandler:
^(FBSession *session,
FBSessionState status,
NSError *error)
{
// if login fails for any reason, we alert
if (error)
{
NSLog(#" login failed");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
// if otherwise we check to see if the session is open, an alternative to
// to the FB_ISSESSIONOPENWITHSTATE helper-macro would be to check the isOpen
// property of the session object; the macros are useful, however, for more
// detailed state checking for FBSession objects
}
else if (FB_ISSESSIONOPENWITHSTATE(status))
{
NSLog(#" sending post on wall request...");
// send our requests if we successfully logged in
[self postOnWall];
}
}];
};
}
- (void)postOnWall
{
NSNumber *testMessageIndex=[[NSNumber alloc] init];
if ([[NSUserDefaults standardUserDefaults] objectForKey:#"testMessageIndex"]==nil)
{
testMessageIndex=[NSNumber numberWithInt:100];
}
else
{
testMessageIndex=[[NSUserDefaults standardUserDefaults] objectForKey:#"testMessageIndex"];
};
testMessageIndex=[NSNumber numberWithInt:[testMessageIndex intValue]+1];
[[NSUserDefaults standardUserDefaults] setObject:testMessageIndex forKey:#"testMessageIndex"];
[[NSUserDefaults standardUserDefaults] synchronize];
// create the connection object
FBRequestConnection *newConnection = [[FBRequestConnection alloc] init];
// create a handler block to handle the results of the request for fbid's profile
FBRequestHandler handler =
^(FBRequestConnection *connection, id result, NSError *error) {
// output the results of the request
[self requestCompleted:connection forFbID:#"me" result:result error:error];
};
// create the request object, using the fbid as the graph path
// as an alternative the request* static methods of the FBRequest class could
// be used to fetch common requests, such as /me and /me/friends
NSString *messageString=[NSString stringWithFormat:#"wk test message %i", [testMessageIndex intValue]];
FBRequest *request=[[FBRequest alloc] initWithSession:FBSession.activeSession graphPath:#"me/feed" parameters:[NSDictionary dictionaryWithObject:messageString forKey:#"message"] HTTPMethod:#"POST"];
// add the request to the connection object, if more than one request is added
// the connection object will compose the requests as a batch request; whether or
// not the request is a batch or a singleton, the handler behavior is the same,
// allowing the application to be dynamic in regards to whether a single or multiple
// requests are occuring
[newConnection addRequest:request completionHandler:handler];
// if there's an outstanding connection, just cancel
[self.requestConnection cancel];
// keep track of our connection, and start it
self.requestConnection = newConnection;
[newConnection start];
}
// FBSample logic
// Report any results. Invoked once for each request we make.
- (void)requestCompleted:(FBRequestConnection *)connection
forFbID:fbID
result:(id)result
error:(NSError *)error
{
NSLog(#"request completed");
// not the completion we were looking for...
if (self.requestConnection &&
connection != self.requestConnection)
{
NSLog(#" not the completion we are looking for");
return;
}
// clean this up, for posterity
self.requestConnection = nil;
if (error)
{
NSLog(#" error");
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:#"error" message:error.localizedDescription delegate:nil cancelButtonTitle:#"OK" otherButtonTitles: nil];
// error contains details about why the request failed
[alert show];
}
else
{
NSLog(#" ok");
};
}
try this code
NSHTTPCookieStorage* cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage];
NSArray* facebookCookies = [cookies cookiesForURL:
[NSURL URLWithString:#"http://login.facebook.com"]];
for (NSHTTPCookie* cookie in facebookCookies) {
[cookies deleteCookie:cookie];
}
NSString *FBBody = [NSString stringWithFormat:#"your message you want to post"];
UIImage *img=[UIImage imageNamed:[NSString stringWithFormat:image naemif you want to post]];
FBFeedPost *post = [[FBFeedPost alloc] initWithPhoto:img name:FBBody];
[post publishPostWithDelegate:self];
[[UIAppDelegate indicator] startAnimating];
IFNNotificationDisplay *display = [[IFNNotificationDisplay alloc] init];
display.type = NotificationDisplayTypeLoading;
display.tag = NOTIFICATION_DISPLAY_TAG;
you should set Permissions:"status_update".
like this :
FBLoginView *loginview = [[FBLoginView alloc] initWithPermissions:[NSArray arrayWithObject:#"status_update"]];
or
FBSession *fbSession = [[FBSession alloc] initWithPermissions:[NSArray arrayWithObject:#"status_update"]];