Publish Feed Story Using Facebook API - iphone

I want to publish information to user's wall from iphone application. I am using the Facebook SDK for iphone. I found in the documentation that I should use FBStreamDialog but this loads a form to the user and s/he write the story to be published, I don't want this behavior. I want to publish user actions at my application and user just needs to click share button, then the application should fill a template story and publish.
I found this use case was available before with FBFeedDialog but this is not supported via the API now.
Any suggestions, what I should do?
//Modified
here's an example for David's solution:
NSString *att = #"{\"name\":\"i\'m bursting with joy\",\"caption\": \"User rated the lolcat 5 stars\", \"description\": \"a funny looking cat\"}";
NSDictionary *attachment = [NSDictionary dictionaryWithObject:att forKey:#"attachment"];
[[FBRequest requestWithDelegate:self] call:#"facebook.stream.publish" params:attachment];

#"stream.publish"

I use this code occur error "The user hasn't authorized the application to perform this action"

Related

Facebook test user vicious circle: Publish_actions

I'm trying to post an Open Graph Story, being logged to my app with Facebook test account. Story contnents: Name shared a link.
Facebook's instructions to get a permission is a vicious circle!
To post I need a permission, For permission I got to post something.
So when I'm trying to post a story from the app. App goes to Facebook app, creates a template for post. But when press "Publish" nothing's happen.
Please, help me to solve a problem.
Our company tried everything, changed code etc, but I think it's Facebooks problem. Please, help me to find out why posts do not publish to Facebook.
PS: We do not use share dialog in this case, we are using Open Graph with API 2
If you just want to share a link then use the following code:
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:#"http://developers.facebook.com"];
[FBSDKShareDialog shareFromViewController:self
withContent:content
delegate:nil];
In the composer leave 'Say something about this...' blank and the story will show up in the Timeline as "Name shared a link"
If it is a custom OG story, then use the Share Dialog; you do not need to explicitly get publish_actions permission.
If Share Dialog does not seem to post to Timeline, set the delegate for the dialog and you can use the delegate method to investigate the cause.
-(void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error {
NSLog(#"Error: %#", error);
}
As for creating actions and objects, you can do so in your app dashboard:
https://developers.facebook.com/apps/<your-facebook-app-id>/open-graph/
If you need permissions to make Graph API calls then implement login with Facebook and it is here that you request the permissions that your app needs. For example:
FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
loginButton.readPermissions = #[#"public_profile", #"user_photos"];
loginButton.publishPermissions = #[#"publish_actions"];
Once you have the permissions in place you can make Graph API calls.

how to get user's posts & updates from Google plus like facebook

I want to get all wall updates of user's google plus account like facebook.
I have seen official link for it which is
Google Plus Documentation for iOS
& I have downloaded sample from there which is here Google Plus SDK Sample
it works well for getting user's information like email id,profile name,user's friend list with images & for posting on google plus.
but I am not getting user's post & updates.
all I want is user's wall updates & user's friends updates from google plus like facebook does.
but from above link i have found nothing for getting wall updates.
I have searched google for this also & get nothing regarding above problem.
any help for above problem appreciated.
Thanks in advance
From a backend server you can easily perform this API call to read a user's public activities. You can see the REST API here:
https://developers.google.com/apis-explorer/#p/plus/v1/plus.activities.list
Combine this with a people.list and you can query for a user's friend activities on Google+.
On iOS, you probably don't want to make these API calls directly from a user's device. If you can, you should offload the work to a backend server to avoid overworking the mobile client. That said, you can perform an API query similar to listing people in circles:
GTLQueryPlus *query =
[GTLQueryPlus queryForActivitiesListWithUserId:#"me" collection:#"public"];
[[[GPPSignIn sharedInstance] plusService] executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLPlusActivityFeed *actFeed,
NSError *error) {
}
If you put a breakpoint in the application on the function, the activities feed will be something like as follows:
(lldb) po actFeed
{
nextPageToken:"CAIQ44qZ58DgtwIgFCgB"
etag:""DOKFJGXi7L9ogpHc3dzouWOBEEg/UMVQXfw8ynZaTz31tpuZo473TsQ""
title:"Google+ List of Activities for Collection PUBLIC"
updated:"2013-07-16T04:04:34.697Z"
kind:"plus#activityFeed" items:[20]
}
The items array contains the actual activities that a user has publicly written on Google+.

Post to facebook and unlock levels

I'm programming my own iPhone game and since I don't want the users to pay for my levels, I'd like to allow them to post something on their FB or twitter timeline. Once it's done, I'd like to unlock the level for free, and do that for each levels pack.
Anyone has an idea on how to do this ? I know I can use Facebook API for iOS to post a status, but how can I ensure the action has been done ?
Each post or tweet has a confirmation delegate method. Add an NSNotification to unlock your level on confirmation completion.
You can do this, it's easy using graph api for FB.
You can say user to post message hardcoded in you code and you receive response from api that message is posted on his wall then you can unlock the level.
Also if you want that user can't edit message then you need to post message in background and it easy like below code.
NSMutableDictionary *dictPara = [[NSMutableDictionary alloc] init];
[dictPara setObject:objSelGameStep.smsg forKey:#"message"];
[dictPara setObject:#"status" forKey:#"type"];
[facebook requestWithGraphPath:#"me/feed" andParams:dictPara andHttpMethod:#"POST" andDelegate:self];
i hope this may help you.

How to use the Facebook API, and how can I post a link with status on the users wall via my app?

I'm trying to post a link + status through my app, using this "popup" facebook window where the user is asked to log in, then asked to allow my app to his profile. Then I want him to be able to write a status, with a link I specify attached. This facebook popup would be triggered by a button, not at start of my app (in the documentation I found that they want me to implement it in the appDidFinish launching method...) But I don't want that, I want it like the popup facebook window is only triggered per button tap.
I'm trying to figure this out for a few days now, but finding that all tutorials are out-dated and the Facebook Developer documentation is very weak- atleast for for me. I already downloaded the Facebook-iOS-SDK with the API and JSON included from GitHub. I already did a few attempts, but the furthest I got is that the user was asked to log in, but not through my app, instead Safari opened and the log in field were there, not in my app.
Could someone please post some code, a basic tutorial I might find helpful, or point me to a good online tutorial? I already tried to post to iPhone Dev SDK forums, where other people also asked for this, but never got any help. So could someone out here please put together something that would help out all the newbies?
I want my login screen look like this, and the rest should be in a popup too:
http://www.facebook.com/photo.php?pid=439332&l=c04b210914&id=100001688115647
Thanks a lot in advance!
There is already a sample code in facebook-ios sdk you can see that there are already the code available for some things. Here is a code snippet from the older facebook API but this should work with the newer graph api too
- (void)setStatus:(id)target {
NSString *statusString = #"Testing iPhone Connect SDK";
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
statusString, #"status",
#"true", #"status_includes_verb",
nil];
[[FBRequest requestWithDelegate:self] call:#"facebook.users.setStatus" params:params];
}
WHat you can do is create a controller to handle all the facebook requests like a singleton class and on tap of button do something like this
- (IBAction)showFBLoginDialog:(id)sender {
if(LoggedInFacebook == NO) {
FBLoginDialog *dlg = [[[FBLoginDialog alloc] initWithSession:faceBookController._session] autorelease];
[dlg show];
}
else {
[faceBookController logoutUser];
}
}
If you need further help search on google and stackoverflow you will find a bunch of.

How do I like a Facebook AppID through IPhone Application?

I am developing a iPhone application in which I want to simply 'Like' my own Facebook AppID.
For Facebook integration I am using FBConnect and Graph API (https://github.com/facebook/facebook-ios-sdk/blob/master/README.mdown).
After researching, I found that I was supposed to use the following method, which I attempted to implement in the "DemoAppViewController.m" of the sample code when the 'publishStream' button was selected:
NSMutableDictionary *params = [NSMutableDictionary dictionary]; //Use an empty dictionary
[_facebook requestWithGraphPath:#"https://graph.facebook.com/163221793740496/likes"
andParams:(NSMutableDictionary *)params
andHttpMethod:#"POST"
andDelegate:(id <FBRequestDelegate>)self];
However, my FBRequest.m 'responseString' indicates: {"error":{"type":"GraphMethodException","message":"Unsupported post request."}}
What am I doing wrong and how can I make this work?
From what I understand, all I need to do is attach my accessToken to https://graph.facebook.com/163221793740496/likes. What exactly does that mean, and how is it accomplished?
Thanks in advance!
P.S. - In case there was any confusion, my post was in reference to having a user sign into Facebook with their account login via a fb like button in the application. After the user allowed the appropriate permissions, my app would 'like' the AppID with the user's account.
You can't programmatically like a page on Facebook. It would be enthusiastically abused.