Broken (grey) thumbnails in Facebook mobile feed? - objective-c

I have an iOS app that posts to users FB feeds with a link, description, and image.
If I check posts that have been made through my app in a full sized browser, I can see that everything, including the thumbnail is showing as expected.
The problem is if I open the FB feed from a mobile browser or the FB iOS app, I get grey boxes instead of thumbnails.
I have tried this multiple times and I get the grey box in mobile pages every single time and all of the Facebook debug data for the link checks out as far as I can see.
The following is the objective-c code that posts the Feed to FB.
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
[params setObject:self.captionTextView.text forKey:#"message"];
[params setObject:[NSString stringWithFormat:#"%#'s photo on Wander", [appDelegate.prefs valueForKey:#"firstName"]] forKey:#"name"];
[params setObject:shortUrl forKey:#"link"];
NSString *imageURL = [NSString stringWithFormat:#"http://%#/mobile/photo.php?p=%#", appDelegate.apiHost, photoParams];
[params setObject:imageURL forKey:#"picture"];
[params setObject:[NSString stringWithFormat:#"%#, %#", [appDelegate.prefs valueForKey:#"cityName"], [appDelegate.prefs valueForKey:#"countryName"]] forKey:#"caption"];
[params setObject:[NSString stringWithFormat:#"I'm using Wander to explore %# with %# as a local guide!", [matchData valueForKey:#"cityName"], [matchData valueForKey:#"firstName"]] forKey:#"description"];
[appDelegate.facebook requestWithGraphPath:[NSString stringWithFormat:#"%#/feed", fbId] andParams:params andHttpMethod:#"POST" andDelegate:self];
[params release];
This is the test URL: http://maruta.wanderwith.us/viewPhoto/index/My0zNA (this might disappear because it's on a development server and I regularly clear data, I'll try my best to keep it live until this gets resolved)
Am I missing something?

I ran into the same situation. Turns out it was the question mark in your URL. Facebook passes your image URL through their own proxy. If your URL contains "?", then it doesn't work through the mobile feed somehow.
Your server expects url in this format: http://hostname/mobile/photo.php?p=1234567889. If you change this to this format: http://hostname/mobile/photo/1234567889, then Facebook will be happy. try mod rewrite if you are using apache.

Related

Posting from my app in Facebook

I would like to update my iOS app to take advantage of iOS 6 Facebook integration. Currently I use the Facebook dialogue. I like the way I can present the dialogue to the user and when it posts it has my app icon and the small tag saying "via my app name" which links to my app.
With the iOS 6 Facebook integration it says "via iOS" and a link to Apple's Website. Is there a way to achieve the same type of result using iOS 6's Facebook integration?
current code:
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"1234567890", #"app_id",
#"http://www.mywebsite.com/page5/page5.html", #"link",
picLink, #"picture",
countDownName, #"name",
#"My app name", #"caption",
#"For the iPhone and iPod Touch", #"description",
theMessage, #"message",
theFriendID, #"to",
#"Share on Facebook", #"user_message_prompt",
nil];
[facebook dialog:#"feed" andParams:params andDelegate:self];
my iOS 6 code (taken from Facebook's sample code)
BOOL displayedNativeDialog = [FBNativeDialogs presentShareDialogModallyFrom:self
initialText:initialText
image: [UIImage imageNamed: #"myImage.png"]
url:url
handler:nil];
if (!displayedNativeDialog) {
[self performPublishAction:^{
// otherwise fall back on a request for permissions and a direct post
[FBRequestConnection startForPostStatusUpdate:message
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
[self showAlert:message result:result error:error];
self.buttonPostStatus.enabled = YES;
}];
self.buttonPostStatus.enabled = NO;
}];
A quick google search showed the following tutorial: http://www.techotopia.com/index.php/IPhone_iOS_6_Facebook_and_Twitter_Integration_using_SLRequest#Facebook_Integration_using_SLRequest
That seems to be a good tutorial to do what you're looking for.
Please try using custom Facebook compose view provided here.

Cancel image upload to Facebook from iOS

I have an app that uploads an image to Facebook. this is the part of my code that does that:
[[self appDelegate] facebooking]; // checke that the user is loged in
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
labeledImage, #"source",
FB_IMG_POST_TITLE,#"message",
nil];
[ [[self appDelegate] getFacebookVar] requestWithGraphPath:[NSString stringWithFormat: #"/me/photos?access_token=%#", self.appDelegate.getFacebookVar.accessToken] andParams:params andHttpMethod:#"POST" andDelegate:self];
I want to
A) make the upload process a different thread.
B) Give the user the option to cancel the upload.
How would I do that?
Firstly, you are not using the facebook SDK correctly. You should not need to explicitly add the access_token. Please see the sample code for this.
You shouldn't need a different thread, the request will be handled asynchronously. What made you think you need to do this?
I'm not sure you can do B) by default. You could change the sdk source to give access to the NSURLConnection (which you can cancel).

How to specify tags when uploading video to Facebook using the Graph API

I'm able to upload videos to Facebook successfully using the latest Graph API via Objective-C. However, I'd like to also tag certain Facebook users who are in the video. I cannot get this to work.
The FB documentation says that there is a "tag" field that accepts an array of objects containing id and name fields. However, if I try to pass a JSON string in this format the video upload fails, without any useful error message. Am I passing the tags data correctly?
Here's sample code that fails. The code succeeds when I remove the #"tags" field from params, or set tagStr to an empty array, i.e. #"[]".
NSString *tagStr = #"[{\"id\":\"<id-removed>\", \"name\":\"<name-removed>\"}]";
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
data, #"video.mov",
#"video/quicktime", #"contentType",
titleStr, #"title",
descStr, #"description",
tagStr, #"tags", // specifying tags fails
nil];
[facebook requestWithGraphPath:#"me/videos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
Your Params Dictionary Should be like this,
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
videoData, #"video.mov",
#"video/quicktime", #"contentType",
#"Birthday wishes", #"title",
#"via Birthday wishes", #"description",facebook.accessToken,#"access_token",
nil];
After the Video gets posted,you can able to tag friends in - (void)request:(FBRequest *)request didLoad:(id)result as like
[APP.facebook requestWithGraphPath:[NSString stringWithFormat:#"%#/tags/%#?access_token=%#", photoID, [ar_tID objectAtIndex:i], APP.facebook.accessToken]andParams:nilandHttpMethod:#"POST" andDelegate:self];

Post to Friend's Wall with iOS Facebook SDK

Is it possible to use the iOS Facebook SDK's dialog method to post to the active user's friends' walls? That is, assuming the correct permissions have been granted?
Using the dialog method, with "feed" as the action, only seems to allow me to post to the user's stream, not to anyone elses. What am I missing?
[facebook dialog:"feed" andParams:... andDelegate:self]
The params only specify the content of the post; there doesn't seem to be any way to specify the profile I want to post to.
Just use the following code:
[facebook requestWithGraphPath:#"[IdOfFriend]/feed" andParams:... andHttpMethod:#"POST" andDelegate:self];
post on friends wall through graph path no more works
your feed action works.. have params like
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Checkout my APP_NAME", #"name",
#"Come visit my APP_NAME", #"caption",
[NSString stringWithFormat:#"I just joined APP_NAME Can you?"], #"description",
#"http://www.friendsmash.com/images/logo_large.jpg", #"picture",
#"FRIEND'S_FB_USER_ID", #"to",
// Add the link param for Deep Linking
[NSString stringWithFormat:#"https://YOUR_WEB_LINK.com/"], #"link",
nil];
Cheers...!

how to publish photo on application profile page using REST api of facebook

i am uploading photo to application(or like) profile page. But it will show error message
"error_code":240,"error_msg":"Requires a valid user is specified (either via the session or via the API parameter for specifying the user."
i am using REST API for facebook.
And this code
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, #"picture",
kAppId,#"uid",
nil];
[_facebook requestWithMethodName:#"photos.upload"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
where kAppId is applicatino ID.
if i remove #"Uid" parameter then photo uploaded to my(user) photo album.
this thing is possible in web that user can upload a photo to like page as news feed.
how we can do it through REST APi
Thanks
You may want to try urlencoding your params using
[params dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];