Sharing Youtube video to Facebook using FBStreamDialog - facebook

I am developing an iPad application in which I need to share a Youtube video link to Facebook.
I am using FBStreamDialog for image sharing as follows:
But, I do not know how to share the video (I wanted to know about the parameters like media type, src, href etc)
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.targetId = <facebookUserId?;
dialog.userMessagePrompt = #"What's in your mind?";
dialog.attachment = #"{\"name\":\"Sample Photo\","
"\"href\":\"http://abstract.desktopnexus.com/wallpaper/250923\","
"\"caption\":\"MyAppName\",\"description\":\"Testing share\","
"\"media\":[{\"type\":\"image\","
"\"src\":\"http://static.desktopnexus.com/wallpapers/250923-bigthumbnail.jpg\","
"\"href\":\"http://abstract.desktopnexus.com/wallpaper/250923\"}],"
"\"properties\":{\"another link\":{\"text\":\"Facebook home page\",\"href\":\"http://www.facebook.com\"}}}"
[dialog show];
Could someone help me?
Thanks and Regards,
Deepa

I have explained here all the Facebook Meta tags which are used for sharing.
You can have a look at this post, it may be useful.

Related

SLServiceTypeFacebook setinitialtext not working

I can't tell why the setInitialText function isn't working in my implementation of SLServiceTypeFacebook. The code I used for Facebook and Twitter are nigh identical except where Facebook replaces the word Twitter, and twitter works just fine. Any help appreciated.
Thanks
if ([buttonTitle isEqualToString:#"Facebook"]){
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewController *faceSheet = [[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook] init];
NSLog(#"%#", messageField.text);//This returns the appropriate string
[faceSheet setInitialText:messageField.text];
//The facebook VC appears, but initial text is not set to messageField.text
[self presentViewController:faceSheet animated:YES completion:nil];
}
}
This certainly is a strange issue, and see as I don't see anything else obviously wrong with this, so here's my suggestion. It is possible that somehow something's getting messed up due to the extraneous initializer you have set on the composer. composeViewControllerForServiceType: already alloc/init's an instance of SLComposeViewController, so there is no need to add init. Replace this:
SLComposeViewController *faceSheet = [[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook] init];
With this line:
SLComposeViewController *faceSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
This is not an issue, Facebook doesn't allow it anymore.Facebook changes its platform privacy policy for share feature. Use below link for reference
https://developers.facebook.com/docs/sharing/ios

Sharing option with iOS app?

i want to share app info on social network with all social networking application that are previously installed in device. i have one demo images just like this, if any idea please give me.
Thanks in advance
Using UIActivityViewController you can Share, apple doc
Example:
UIImage *anImage = [UIImage imageNamed:#"SampleImg.png"];
NSArray *Items = [NSArray arrayWithObjects:
#"your app info",
anImage, nil];
UIActivityViewController *ActivityView =
[[UIActivityViewController alloc]
initWithActivityItems:Items applicationActivities:nil];
[self presentViewController:ActivityView animated:YES completion:nil];
Here’s a UI control called REActivityViewController from Roman Efimov that looks like a UIActivity view, but allows for full color icons, total customization, and the control works with iOS 5.0. The control looks and works as expected on iPhone and iPad.
This is not simply a control that looks like UIActivityController, but also makes it much easier to create custom activities.
Here’s an example from the readme showing how easy it is to create a custom activity controller:
REActivity *customActivity = [[REActivity alloc] initWithTitle:#"Custom"
image:[UIImage
imageNamed:#"REActivityViewController.bundle/Icon_Custom"]
actionBlock:^(REActivity *activity, REActivityViewController *activityViewController){
{
[activityViewController dismissViewControllerAnimated:YES completion:^{NSLog(#"Hey, there!");}
];
}];
Try this.Happy coding.

ShareKit for Facebook in iPhone application

I can't get ShareKit to work. I dragged ShareKit into my app with checked copy option. I also updated the shkconfig file with my Facebook key, secure key, and used the following code:
SHKItem *item = [SHKItem text:#"Praveen Kumar Tripathi"];
SHKFacebook *faceBook=[SHKFacebook shareItem:item];
[faceBook share];
in viewDidLoad.
But I'm not able to see Facebook screen. I'm seeing a blank screen.
You weren't completely clear, so I'm not sure what your asking, but it sounds like you want to show a facebook login at launch. The way you do that is like this:
First, #import "SHKFacebook.h"
then in your button, put then in the viewDidLoad:
SHKItem *item;
this creates the sharekit item
then:
NSURL *url = [NSURL URLWithString:#"http://itunes.apple.com/us/app/...?mt=8"];
put the link to your app here. This link is so if someone clicks on the Facebook post, they will be directed to the iTunes store to download your app.
Then set the basic text for your post. This text is set by you. The user Cannot change this text. (Obviously this is what I do, you can make this text anything you want)
item = [SHKItem URL:url title:[NSString stringWithFormat:#"I'm playing someGame on my iPhone! My Highscore is %i, think you can beat it?", highScoreInt]];
Then set up the post like this:
item = [SHKItem URL:url title:#"Share Me!"];
finally show the item:
[SHKFacebook shareItem:item];
I hope this helps.

posting UIImage to facebook along with other text

i'm trying to post an image on facebook using the following code.
FBStreamDialog* dialog ;
if([FBSession session].isConnected)
dialog = [[[FBStreamDialog alloc] initWithSession:[FBSession session]] autorelease];
else
dialog = [[[FBStreamDialog alloc] initWithSession:session] autorelease];
dialog.attachment = [NSString stringWithFormat:#"{\"name\":\"%#\",\"media\":[{\"type\":\"image\",\"src\":\"%#\"}]}", strEventStatus,eventImg];
[dialog show];
Does the media tag have any other property apart from src which would take and image in form of NSData? how do i post the image otherwise?
While you are linking the attachment property for a Image the source should be a URL.. I dont think You can post a UIImage by using attachment.. One solution is you can have a webservice for posting the image in your server and then give that URL when you are posting.
I dont know which Facebook API you are using..
This what i did to upload a image by using Facebook Graph API
UIImage *img = [UIImage imageNamed:#"myImage.png"];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, #"picture",
nil];
//facebook is a facebook Obj which I initialized before
[facebook requestWithMethodName:#"photos.upload"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
I have no knowledge of the Facebook API you are using, but it would seem Image SRC would imply that the image is already somewhere on the web.
Have you considered uploading the image to a server somewhere and using the SRC of the image as a URL?
I hope this helps!
You can directly take a UIimage and upload via the code used by BuildSucceeded, you no longer need to forward the image to a server and link via URL. You can also call the image from a UIimageview, camera or library.

picking and uploading the video for iphone 3g ios 4

I want to upload a video from iPhone to a server somewhere.
I have found this useful question here for uploading a video on the server from iPhone.
The only problem here is picking the video. The code is using uiimagepickercontroller to pick up the video and I have a 3g phone which has not video in its photos app. I can't even put a video in it . I have a video only in iTunesU . Currently I am using following snippet for uiimagepickercontroller .
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum]) {
UIImagePickerController *picker =
[[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
}
else {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:#"Error accessing photo library"
message:#"Device does not support a photo library"
delegate:nil
cancelButtonTitle:#"Drat!"
otherButtonTitles:nil];
[alert show];
[alert release];
}
So I have to ask that is it necessary to pick a video from uiimagepickercontroller and if so how can I do so with my iPhone 3G .
Please tell me if the question is not readable.
Thanks .
There is no video support for 3G that I am aware of.
In order to make it work (you could simulate it) you need to pass a mediaType of 'kutTypeMedia', which errors as not available on your device.
'If' you want to test, you can copy a video from the bundle, into your Camera Roll and test on the simulator.
Something like this to copy the video from the bundle to your camera roll:
Copy a video file from your bundle and save it to the album as below!
"Bundle Path :
(Where APPLCIATIONGUID and user are dynamic and depend on the logged on user and the applicationGUID)
'/Users/user/Library/Application Support/iPhone Simulator/4.0/Applications/APPLICATIONGUID/Documents'
Where APPLICATIONGUID is the GUID associated with your particular project. You can confirm that you are in the right folder by looking for the appropraite .app file.
Note:// I don't believe that this will work with a MOV but have tried nothing but a .m4v.
NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:#"Documents/VID_0001.m4v"]];
NSString *videoFilepath = [[NSBundle mainBundle] pathForResource:#"VID" ofType:#"m4v"];
NSLog(#"Filepath is: %#", videoFilepath);
//test video can save to the photos album first - code missing
UISaveVideoAtPathToSavedPhotosAlbum(filePath, self, #selector(video:didFinishSavingWithError:contextInfo:), nil);*
Once this has been done - videos are available in your photo album for selecting should you be setting up your UIImagePickerController with the correct media type.
This is the only option I see that you have to work with Video without a 3GS.