iOS Facebook SDK - Posting A UIImage To User's Wall - ios

Ok so there is a lot of threads on this, but nothing seems to work for me.
My app allows users to post a photo (which is a UIImage created by a screenshot of the App) to facebook.
However, I can currently only post the photo by using:
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:[[appDelegate facebook] accessToken], #"access_token",nil];
[params setObject:#"Caption" forKey:#"name"];
[params setObject:[self captureScreen] forKey:#"source"];
if([[appDelegate facebook] requestWithGraphPath:#"me/photos" andParams: params andHttpMethod: #"POST" andDelegate:(id)self]){
[self.view addSubview:[Memos showMemo:facebookMemo]];//Show success alert
}
This works fine, but doesn't use any sort of FB Dialog.
I really want to use the dialog so users can feel like it is more "facebook official" and allow them to preview/confirm the post.
Is there any SIMPLE way to go about doing this?
This is the closest I have gotten: Post photo on user's wall using Facebook iOS SDK, but I have issues with these lines:
currentAPICall = kAPIGraphUserPhotosPost;
As xcode doesnt recognize any of the kAPI... objects...
Suggestions?

Related

Facebook requests example project

Has anyone found an example project for this tutorial on facebook requests: http://developers.facebook.com/docs/howtos/send-requests-using-ios-sdk/
Since I have already integrated a list of facebook friends a user has, can I send each a message?
You can find the actual project on GitHub, https://github.com/fbsamples/ios-3.1-howtos/tree/master/SendRequestsHowTo
If you already have a list of Facebook friends you can just send them a message. Just get a comma-separated, string representation of those friends, and pass the info to the "suggested" parameter:
NSString *friendList = #"12345, 4567";
NSMutableDictionary* params =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Check this out.", #"message",
friendList, #"suggestions",
nil];
[self.facebook dialog:#"apprequests"
andParams:params
andDelegate:self];

Facebook post from IOS not working

I am trying to post something from my IOS app to facebook feed. Below is the test I included in my code.
Facebook *facebook = [[Facebook alloc] initWithAppId:FB_APPID_REMOTE andDelegate:self];
// Create the parameters dictionary that will keep the data that will be posted.
NSMutableDictionary *fbParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"My test app", #"name",
#"http://www.google.com", #"link",
#"FBTestApp app for iPhone!", #"caption",
#"This is a description of my app", #"description",
#"Hello!\n\nThis is a test message\nfrom my test iPhone app!", #"message",
nil];
[facebook requestWithGraphPath:#"me/feed" andParams:fbParams andHttpMethod:#"POST" andDelegate:self];
However, I do not see the post updated to my facebook feed. Am i missing out anything here?
The method requestWithGraphPath returns an object of FBRequest. So you can check request.state to determine the status of the request, and check request.error to know what's exactly the problem.
Using AppDelegate will result in returning to the same page View you called from the ViewController. But as you are not getting any obvious error log or crashes, I think it is some issue with the Facebook graph protocol.
Replace "me/feed" with just "feed" as that works fine for me.

Can't get the Facebook publish_action permission on iOS

I've spent hours on this and can't get it to work. Basically I just want a button in my app that will 'Like' itself on Facebook.
I've created the app on dev Facebook and have an associated App Page.
In my code I request these permissions:
_permissions = [NSArray arrayWithObjects:#"publish_stream", #"publish_actions", #"user_birthday", nil];
I can retrieve a profile picture fine, but when I try to 'Like' using this code:
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
_facebook.accessToken, #"access_token",
nil];
[_facebook requestWithGraphPath:#"329756493773381/og.likes" andParams:params andHttpMethod:#"POST" andDelegate:self];
I get this error response:
(facebookErrDomain error 10000.)" UserInfo=0x20090590 {error={
code = 200;
message = "(#200) Requires extended permission: publish_actions";
type = OAuthException;
}}
When logging in on the app, Facebook asks me for permission to see my birthday, and tell's me it will Post on my behalf but it seems to not get the publish_actions permission.
Is there something i'm missing that I need to do?
I see Temple Run has a Facebook Like button and offers bonus coins for pressing it. This is what I wish to achieve.
EDIT -------
I've changed my permissions to just #"publish_actions", #"user_birthday" and now the auth dialogue says
"This app may post on your behalf, including objects you liked and
more"
which seems to be the publish_actions permission, however I was still getting the error
message = "(#200) Requires extended permission: publish_actions";
I've changed this line:
[_facebook requestWithGraphPath:#"329756493773381/og.likes" andParams:params andHttpMethod:#"POST" andDelegate:selrf];
to this:
[_facebook requestWithGraphPath:#"329756493773381/og.likes" andDelegate:self];
and I do now get a response back, although it doesn't post a 'like'
This is the result response:
{
data = (
);
paging = {
next = "https://graph.facebook.com/329756493773381/og.likes?sdk=ios&sdk_version=2&access_token=BAAGeAp3ZBGwoBAPICjlgB5zK0YECyP8yElf8hJoMrx8Qs4vjeZAK5PlXFAVbGM1JyXHE0wZBvU0aBeCzCUTZBejQgoJ44CAIQsrG64TfrHdxjMqWD&format=json&offset=25&limit=25";
};
}
Any idea what to try next?
EDIT 2 ---------------
I'm making progress with this.
I've added the users id to the graph request like this
NSString *graphPath = [NSString stringWithFormat:#"%#/og.likes",facebookID];
and used these parameters
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"AAAGeAp3ZBGwoBABvKjsPZAoQQNG9cDPJI2v2TI8acyyPSNtm9ZBkfydHqVZAjSKWSbLuvFwxyxSrCts7kFZCnh7Y6f5PFNlWb6smF8XF33wlRZBgfLyhT1", #"access_token",
#"http://samples.ogp.me/329756493773381", #"object",
nil];
and now I get a like showing up on my timeline :-)
I was using the access-token supplied by the Facebook login, but it seems the one supplied by the graph object is different.
Now, the like that i'm seeing has this pattern:
Darren likes object on MyAPP
Is it even possible to have it as
Darren likes MyAPP
with it linking to the app Facebook page?
Thanks
Check if you have done the steps below:
https://developers.facebook.com/docs/opengraph/tutorial/
"Note: The user-prompt for this permission will be displayed in the first screen of the Enhanced Auth Dialog and cannot be revoked as part of the authentication flow." - link
Try this if you havent already:
Auth Dialog -> Configure how Facebook refers users to your app - > Add publish_actions permissions.
https://developers.facebook.com/docs/opengraph/authentication/
"To enable the new Auth Dialog, go to the App Dashboard, and enable the Enhanced Auth Dialog setting in the Advanced section of your app." -link
Hope this helps!
This seems to be the same problem I was having on this SO question:
Facebook iOS SDK 3.0, implement like action on a url?
But if you want to like you facebook page in the app, there is no way to do that in Objective C. Only with the javascript Like button which you can generate here:
https://developers.facebook.com/docs/reference/plugins/like/
The way Temple Run does it is to display the Like button in a web-view, so their like button is actually on their server, this is perhaps an ugly-hack but will work for liking a page.

Can I avoid Captcha dialog when posting picture using Feed Dialog in iOS SDK?

I am using the dialogs in Facebook iOS SDK to allow users's of our app to share a link on their news feed (SDK downloaded today to ensure I have latest version). This was working last week and began behaving differently last Friday after an outage of the API service and a capture dialog is now appearing before the user can post. But the captcha image doesn't load and it says Unknown Error in the top right corner of the captcha dialog which is ugly and seems incorrect.
Has the Facebook API changed recently to now require captcha when posting picture or link? If I remove either picture or link from the params then the post dialog loads fine. I've tried a variety of different urls for my picture or link value and nothing seems to work except removing that param completely which I don't want to do. Can I post a picture or link without the captcha step?
This is my code.
- (void)publishStream:(NSString *)postName caption:(NSString *)caption
{
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary
dictionaryWithObjectsAndKeys:
#"Company Website",
#"name",
#"http://mycompanysiteurl.com",
#"link",
nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
kAppId, #"app_id",
#"http://mypictureurl.png", #"picture",
postName, #"name",
caption, #"caption",
actionLinksStr, #"actions",
nil];
[_facebook dialog:#"feed" andParams:params andDelegate:self];
}
I've tried various combinations of permissions when authorizing too with no luck (publish_stream, read_stream, publish_actions, photo_upload).
Not sure if I'm missing something obvious by I've been trying to fix this for days and have not found a solution other than removing the picture or link which is not an option for me due to requirements.
Thanks in advance.

iPhone FBConnect, dashboard.addnews

How to add news via FBConnect?
I have the following code:
NSString *newsBody = #"[{\"message\": \"News message\" }]";
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:newsBody forKey:#"news"];
[[FBRequest requestWithDelegate:self] call:#"facebook.dashboard.addnews" params:params dataParam:nil];
After I sent the request I received the success responce. But I can't see the new news in the facebook account.
Also, I tried to add full info into news parameter (http://wiki.developers.facebook.com/index.php/Dashboard.addNews):
NSString *newsBody = #"[{\"message\": \"News message\",\"action_link\": {\"text\": \"link text\",
\"href\": \"http: //google.com\"} }]";
But this request returns error.
Any ideas?
I found the answer. The FBStreamDialog should be used to publish the news. It means that the custom interface cannot be used for this purposes. :(
Also, just wanted to say that FBConnect it's a one big mess!! Currently fighting with the bug when after clicking Cancel button in the FB dialog the dialog firing the event dialogDidSucceed but not dialogDidCancel. Such a big mess!!!

Resources