How to share without links/images/media with iOS Facebook SDK? - sharing

I've gone through the Facebook Sharing Guide, and there's one simple thing I can't seem to do (without the built-in dialog): how do I simply share a status text?
I've tried the following code after some StackOverflow browsing:
FBSDKShareAPI * shareApi = [[FBSDKShareAPI alloc]init];
shareApi.message = self.fbMessage.text;
shareApi.delegate = self;
[shareApi share];
However, that fails with FB SDK Error 2 "Share content cannot be null". Seems like I am obligated to fill in the shareApi.content property with one of the content objects: link/photo/video/multimedia. But I really don't want to attach any of these...
How do I simply post a status text message?

Ok found a solution using FBSDKGraphRequest:
NSDictionary *params = #{#"message": self.fbMessage.text};
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:#"/me/feed"
parameters:params
HTTPMethod:#"POST"];
[request startWithCompletionHandler:nil];

Related

Google plus share opens link in browser

I am just trying to implement an iPhone app, that has a feature to share on Google+. So, when I click on share button, it is opening the link in safari. Instead, I would like to have it like Facebook pop-up window. Is there any possibility to implement it?
- (IBAction) didTapShare: (id)sender {
share = [[[GooglePlusShare alloc] initWithClientID:kClientID] autorelease];
/* share.delegate = self; // optional
appDelegate.share = share; //optional*/
[[[[share shareDialog] setURLToShare:[NSURL URLWithString:#"URL_TO_SHARE"]] setPrefillText:descStr] open];
[[share shareDialog] open];
}
This is the code, I’ve used for sharing. And I look up on the GooglePlusShare class, I couldn’t figure out anything possible. Thanks in advance!
I think , right now , this is the preffered way to post on google plus..And
After all. after posting status on google plus..it also comes back to your app..

how can i post large size image with hyperlink to Facebook from iPhone programmatically

hi
i need to post large size image with hyperlink from iPhone to Facebook wall programmatically.here i used Facebook SDKs to post image and i used "me/photos". this is my code to post image.
- FbGraphFile *graph_file = [[FbGraphFile alloc]
initWithImage:myImage];
[variables setObject:graph_file forKey:#"file"];
NSString *strMovie=[dicDetails objectForKey:JSON_MOVIENAME];
NSString *strUsername=[[[DTO_Handler start]DTO_dicLogin]objectForKey:JSON_FNAME];
NSURL *url = [[NSURL alloc] initWithString:#"http://www.moviemouse.com/"];
NSString *strMessage=[NSString stringWithFormat:#"%# %# %# %# %#",strUsername,#" likes the movie '",strMovie,#"' via
MovieMouse.",url];
[variables setObject:strMessage forKey:#"message"];
FbGraphResponse *fb_graph_response = [fbGraph doGraphPost:#"me/photos" withPostVars:variables];
i can post image in Facebook wall.but i can't link. i need exactly as same like image given below. if i click "instagram" it will redirect to some url.how can i post like this.
Waiting for a solution. please help me
You can only put the HTTP URL you want to “link” to into the message parameter, as pure text.
Making it a clickable link is what Facebook will do on their own when showing the message on the user’s wall.
Should work exactly the same way, as if the user was uploading the image directly on facebook.com, and typing the message text containing an URL.

Facebook Sharing Window Issue

I am using Sharekit for Facebook sharing on my iPhone app. I had used used the following code for setting the app icon in the sharing window. It works fine except during first time login to Facebook.
NSURL *url = [NSURL URLWithString:#"http://google.com"];
shareScore_ = [SHKItem URL:url title:[NSString stringWithFormat:#"Share Message" contentType:SHKURLContentTypeUndefined];
shareScore_.facebookURLSharePictureURI = #"http://edibleapple.com/wp-content/uploads/2009/04/apple_rainbow_logo.jpeg";
[SHKFacebook shareItem:shareScore_];
During first time login it displays the image in http://google.com and if the user is already logged in it displays the correct image in icon_url. Is there any solution for this?
First Time Login ScreenShot:
Already Logged In Screenshot:
It was a bug in ShareKit - it is fixed now. Please update.

Load static google map into UIImageView?

I'm trying to show a small static google map in my app. I'm wondering if it's possible to do this using UIImageView? It doesn't seem to be working for me but maybe I'm doing something wrong.
This is what I have (I stripped the URL so that it's easier to read):
NSURL *mapurl = [[NSURL alloc] initWithString:#"http://maps.google.com/maps/api/staticmap?[...]"];
NSData *mapdata = [[NSData alloc] initWithContentsOfURL:mapurl];
UIImage *uimap = [[UIImage alloc] initWithData:mapdata];
self.map.image = uimap; // map is my UIImageView
[mapurl release];
[mapdata release];
[uimap release];
I know my UIImageView is setup correctly because if I replace the URL with one of an image then it loads fine. Also I know the google maps URL is correct because if I load it straight into a browser it shows up fine.
I'm starting to think that this might not be possible. If anyone has any ideas or alternatives please share.
Thanks.
Well I ended up finding a solution for this so I'll post it in case someone else runs into the same issue.
First I changed the way I load the image to using NSURLConnection. I don't think this particular change makes a difference but this is what allowed me to find the problem. When trying to load the URL I got a "bad url" error. So I did some searching on that and turns out there are some invalid characters in the google static map URL that must be escaped.
So basically just call this on the url and you should be good to go:
// The URL you want to load (snipped for readability)
NSString *mapurl = #"http://maps.google.com/maps/api/staticmap?[...]";
// Escape the string
mapurl = [mapurl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
I haven't tested this solution with the code I have in my original post but I did test it with my new NSURLConnection implementation and it works perfectly. I assume it'll work fine with the code above as well since it was just a matter of escaping the string.

Using TwitPic API from ObjectiveC/iPhone

There's a similar question on here about this which I've read and I've tried to follow the advice given there... and I think I'm 95% complete but the remaining 5%... well you know ;-)
So I'm trying to call the twitPic API to upload an image and I've got the image contained in a UIImageView which I'm displaying on the screen (I can see it so it's definitely there). My code to form the API call looks like this:
NSURL *url = [NSURL URLWithString:#"http://twitpic.com/api/upload"];
NSString *username = #"myUsername";
NSString *password = #"myPassword";
NSData *twitpicImage = UIImagePNGRepresentation(imageView.image);
// Now, set up the post data:
ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
[request setPostValue:twitpicImage forKey:#"media"];
[request setPostValue:username forKey:#"username"];
[request setPostValue:password forKey:#"password"];
// Initiate the WebService request
[request start];
I get an error back from it stating 'image not found'.
Is it obvious what I'm doing wrong? Any hints at all? I'm only a week deep in ObjectiveC so it's quite likely it's a real newbie error.
On the same track - it's not clear to me how I can capture a success or failure properly in code here - I'm currently dumping the 'request responseString' to an alert which isn't the best thing - how can I check the result properly?
I've also seen the use of 'NSLog' - which I suspect is a debugging/console logging tool - but I can't see the output from this anywhere in XCode - it doesn't SEEM to be shown in the debugger - any clues at all?!
Sorry if the above is really dumb - I can take a little ridicule - but I'm kind of isolated with my iPhone adventures - no one to bounce anything off etc - so I'm venting it all off here ;-)
Cheers,
Jamie.
You need to use the setData method to copy the image data into the post, like this:
[request setData:twitPicImage forKey:#"media"];
You're making a synchronous call, which is going to stall your app while you upload all that image data - you might want to switch to using an NSOperationQueue, or the ASINetworkQueue subclass that allows you to show a progress bar.
You should be able to see NSLog output in the debugger window of XCode. Make sure you've switched to this (control top left with a spray can on). You can also launch the console.