Unable to set picture property in FacebookShareParams ios - ios

I am unable able to set the picture property in Facebook share params.
Every time I set it, it always remain nil:
NSURL *url = [[NSURL alloc] initWithString:filePath];
// Check if the Facebook app is installed and we can present the share dialog
FBLinkShareParams *params = [[FBLinkShareParams alloc] init];
params.link = [NSURL URLWithString:#"https://www.google.com"];
params.name = #"Check if it works";
params.caption = #"Yet to fix image capture and publishing it";
params.picture = url;
What is the problem in there?

Related

Share an image from my app to facebook

I have a movie quiz app, and I want users to share the movie scene image that they are stuck on to Facebook so they can ask their friends for help.
With Facebook's recent changes I am struggling to figure out how to post the image that the user is up to.
All the movie scene images are stored in the app so there is no URL.
I am trying to get the image from my array like this:
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.imageURL = [NSURL fileURLWithPathComponents:[[mainInfoArray objectAtIndex:index] objectForKey:PHONE_IMAGE]];
but it does not work.
Any ideas please to get this to work?
Thank You
First, you create the content, then you create a share-button with that content.
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = image;
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = #[photo];
FBSDKShareButton *button = [[FBSDKShareButton alloc] init];
button.shareContent = content;
[self.view addSubview:button];

FBSDKShareLinkContent is not tagging people with the peopleIDs I set

I'm following the Facebook SDK documentation at https://developers.facebook.com/docs/ios/getting-started/share-button and the people I tag via peopleIDs are not tagged in the post that I share.
NSURL *imageURL = [NSURL URLWithString:#"http://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Facebook_Headquarters_Menlo_Park.jpg/2880px-Facebook_Headquarters_Menlo_Park.jpg"];
NSURL *contentURL = [[NSURL alloc] initWithString:#"http://en.wikipedia.org/wiki/Facebook"];
FBSDKShareLinkContent *content = [FBSDKShareLinkContent new];
content.contentURL = contentURL;
content.contentTitle = #"My Share Title";
content.contentDescription = #"Lorem ipsum dolor sit amet.";
content.imageURL = imageURL;
content.peopleIDs = #[#"10206439771816757"];
content.placeID = #"166793820034304";
content.ref = #"myRefId";
I modified the sample code to use an ID for a person who is a friend and they are not getting tagged. How do I tag friends?
There's some weirdness going on with this API call, as revealed in this other SO post, FBSDKShareLinkContent is not setting the contentDescription and contentTitle, so I'm wondering if there is some trick to getting people tagged.
Update:
It turns out the tagging works if you use the FBSDKShareButton to share the url. However, I want to share and tag people using a FBSDKShareDialog. I can't seem to find a way to do this.
I ran into the same problem, and it appeared to me that tagging people is only supported when using the native app to display the share dialog.
My solution was to try FBSDKShareDialogModeNative first, and otherwise fall back to the default FBSDKShareDialogModeAutomatic:
- (void)shareLinkContent:(FBSDKShareLinkContent *)linkContent fromViewController:(UIViewController *)viewController
{
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
dialog.fromViewController = viewController;
dialog.shareContent = linkContent;
// Try the native mode first. If it isn't supported,
// fall back on automatic mode.
dialog.mode = FBSDKShareDialogModeNative;
if (![dialog canShow]) {
dialog.mode = FBSDKShareDialogModeAutomatic;
}
[dialog show];
}

How to Share Link on Facebook using FBSDKShareLink?

FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:#"http://en.wikipedia.org/wiki/Facebook"];
NSURL *imageURL =
[NSURL URLWithString:#"http://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Facebook_Headquarters_Menlo_Park.jpg/2880px-Facebook_Headquarters_Menlo_Park.jpg"];
content.contentDescription=#"This is facebook test";
content.contentTitle=#"Hello";
content.imageURL=imageURL;
FBSDKShareButton *shareButton = [[FBSDKShareButton alloc] init];
shareButton.shareContent = content;
shareButton.center = self.view.center;
[self.view addSubview:shareButton];
I used facebook-ios-sdk-3.24.0.pkg and I am using the above code for link sharing on facebook using fbsdksharekit. This code is working fine but after closing the xcode and reopen that xcode6.0 it shows the below error.
FBSDKCoreKit/FBSDKCoreKit.h and FBSDKShareKit/FBSDKShareKit.h not found.
i import those frameworks i.e FBSDKCoreKit/FBSDKCoreKit.h and FBSDKShareKit/FBSDKShareKit.h to viewcontroller.m file .
can any one tell me what is the problem.Thanks in advance.
Use the Below Code to Share on Facebook, download latest Facebook SDK
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:#"http://en.wikipedia.org/wiki/Facebook"];
NSURL *imageURL =
[NSURL URLWithString:#"http://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Facebook_Headquarters_Menlo_Park.jpg/2880px-Facebook_Headquarters_Menlo_Park.jpg"];
content.contentDescription=#"This is facebook test";
content.contentTitle=#"Hello";
content.imageURL=imageURL;
[FBSDKShareDialog showFromViewController:self withContent:content delegate:nil];

Open Facebook app with predefined text to share

Please take a look at this piece of code:
NSString *text = [NSString stringWithFormat:#"%#",
[#"Hello world!" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *post = [NSString stringWithFormat:#"fb://publish/profile/me?text=%#", text];
NSURL* url = [NSURL URLWithString:post];
if ([[UIApplication sharedApplication] canOpenURL:url])
{
[[UIApplication sharedApplication] openURL:url];
}
By means of this code I would like to open Facebook app installed on the device and open it on a share dialog with the text string used as a predefined text to share. But unfortunately what it does is just open my timeline. What am I doing wrong? Or is it even possible? I can't find any documentation or tutorial on how to do that properly. Thanks
There is simple way using FacebookSDK's framework. This takes only 2 minutes to go.
FBSDKCoreKit.framework
FBSDKShareKit.framework
If in your device facebook app is not installed then this will open default web browser.
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKShareKit/FBSDKShareKit.h>
// in viewdidload or somewhere else
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentTitle = #"Scare Prank";
content.contentDescription = #"Someone just got Scare Pranked with ♫";
content.contentURL = [NSURL URLWithString:soundUrl];
content.imageURL = [NSURL URLWithString:#“some icon url”];
FBSDKShareButton *button = [[FBSDKShareButton alloc] initWithFrame:CGRectMake(0, 0, 200, 43)];
button.center = self.center;
button.shareContent = content;
[self addSubview:button];

getting video thumbnails from vimeo

In my app i want to display the videos uploaded by a particular user in his Vimeo account.
I have completed the OAuth steps and got the video_id's of the video's uploaded by user. I tried to download the thumbnails for videos so that they can be displayed in table view or collection view.
Vimeo has provided the api method using that i got the response like this:
NSURL *url = [[NSURL alloc] initWithString:#"http://vimeo.com/api/rest/v2?format=json&method=vimeo.videos.getThumbnailUrls&video_id=72961770"];
but i pasted the user id there. i tried another approach so that the user id is loaded dynamically.
NSURL *url = [[NSURL alloc] initWithString:#"http://vimeo.com/api/rest/v2?format=json&method=vimeo.videos.getThumbnailUrls"];
OAMutableURLRequest *request = [[OAMutableURLRequest alloc]initWithURL:url consumer:consumer token:token realm:nil signatureProvider:nil];
OARequestParameter *p0 = [[OARequestParameter alloc] initWithName:#"video_id" value:[array objectAtIndex:0]];
NSArray *params = [NSArray arrayWithObject:p0];
[request setParameters:params];
but i got an error saying that Msg = Method not found.
can you help me to get the id dynamically or is there a way to give the video_id as a parameter to the url. Thank you
create a string for url and paste until video_id=.
NSString *url = #"http://vimeo.com/api/rest/v2?format=json&method=vimeo.videos.getThumbnailUrls&video_id=";
and after that use stringByAppendingString method to append the video_id value to it and use it.
This is also not a direct way but somehow enables you to get the video thumbnails dynamically without having to paste it

Resources