Share Gif image on facebook in ios - facebook

how to share .gif image in Facebook from my ios app?
i have tried png and jpg format it works .
but when i share .gif file.
it will just share as normal image not as an animated image.
so if anybody had try it. please help me out to find solutions.

Source: Guide to Animated Gifs for Facebook
If you try to upload a GIF to Facebook, a still image of the first
frame will appear. However, there are three ways to try and outsmart
the system.
Make a Youtube video look like a GIF.
Use a third party app on Facebook like Animated Picture. For this app, you do not use your own files. There are hundreds
sorted out in different categories to choose from.
Post a link to the GIF. Yes, the still image will show up, but a description will accompany it. Yes, it may take more time, but
your friends will be curious as to what it entails.
But, if the GIF you want to upload is not a moving picture, it should
work just fine. If you have a GIF image that is a nonmoving image, you
should have no problem uploading it to Facebook. According to the
Facebook Developers page, GIFs are one of many file types allowed for
uploading to the platform. Other supported image file types include
JPG, PNG, PSD, TIFF, JP2, IFF, WBMP and XBM images.
PS: This was the first result that I got when I googled about it. You'll find plenty of other sources for doing the same. For example: You Can Finally Put GIFs on Facebook.

if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:#"facebook://app"]]){
NSLog(#"imag %#",_GIFURL);
self.documentationInteractionController.delegate = self;
self.documentationInteractionController.UTI = #"com.facebook.photo";
self.documentationInteractionController = [self setupControllerWithURL:_GIFURL usingDelegate:self];
[self.documentationInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
}
else {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:#"facebook not installed." message:#"Your device has no facebook installed." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}

Use UIActivityItemProvider and extend - (id)item {} for Facebook:
Just upload the GIF to Giphy, then provide the Giphy URL to UIActivityViewController instead of the file contents, Facebook will recognize it and show the animated GIF
- (id)item
{
if ([self.activityType isEqualToString:UIActivityTypePostToFacebook]) {
// Upload to Giphy
...
return [NSURL URLWithString:giphyURL];
}
}
full code is in my GitHub, I am actually a iOS newb so some experts please correct me and the code if possible

Related

Video searching

I'm developing app for IPhones where users clicks button, gets the list of all videos from his IPhone and uploads chosen video to server.
I know how to upload video to server, but I don't know how to implement video searching.
How can I get pathes to all videos (in users IPhone) in Array?
(Currently my IPhone is unavailable for use, so I'd like to know also how to test video search in IPhone Simulator?)
Kind Regards
You need to use the UIImagePickerController component, configuring it to show only videos when browsing the library.
You can do that by setting the mediaTypes property of the picker in this way:
myImagePickerController.mediaTypes =
[[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
Then if you want to test it in the simulator, you need to save some videos on it and you can use the UISaveVideoAtPathToSavedPhotosAlbum function to achieve that. Check out this great answer for more detailed instructions.
This link shows how to access only videos from the photoroll since all videos of the device should be stored there, you should be able to access them from there: Picking video from PhotoLibrary with UIImagePickerController in OS 3.1

How can I get the Thumbnail from Youtube URL?

NSURL *youTubeURL = [NSURL URLWithString:#"http://www.youtube.com/watch?v=HPwyVw_6vsQ&feature=youtu.be"]; // URL is a string which needs to be placed in #"" and close method call with ].
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:youTubeURL];
imageSel = [player thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame];
I am using this code for getting thumbnail from the video and this return null value in the
imagesel.can anybody help me to solve this problem I am using YouTube URL .when I am using this code for the video that is in the main bundle then it is working fine.
Do this:
Firstly extract videoID from Video URL Link.
Now refer this link for getting thumbnail of video.
each youtube link has 4 thumbnail
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
this code is very good for
for example
i have this link:
http://www.youtube.com/watch?v=HPwyVw_6vsQ&feature=youtu.be
and the youtube video id is:
HPwyVw_6vsQ
and generated thumbnail from this link is:
http://img.youtube.com/vi/HPwyVw_6vsQ/1.jpg
this is very easy to use
if someone wants HQ image use this link
https://img.youtube.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg
If you have a YouTube watch page URL, and you want to get the thumbnail URL, the "correct" way to do that is to use oEmbed:
http://apiblog.youtube.com/2009/10/oembed-support.html
That way you don't have to attempt to parse the video id out of the URL.
But... what you really should be doing is using a iframe embed to display videos in your web page (or UIWebView). The YouTube API Terms of Service covers the supported ways of accessing YouTube content:
https://developers.google.com/youtube/terms

How can I tweet videos from an iPhone app?

How can I tweet videos from an iPhone app programmatically ?
(the absence of programmatically caused me 3 vote downs :D)
Is there a way I can attach a video to a tweet ? Or should I upload the video somewhere else and just tweet the link ?
Any guidance in this regard is much appreciated. Thanks.
You need to upload the video, then link it in. You can't really 'attach' anything to a tweet.
i have same question, how to attach video to tweetsheet programmatically. only found code for setting tweetsheet text, image, or url link. looks like need to upload the video (eg. to amazon s3), then add video's url to tweetsheet ->
[tweetSheet setInitialText:#"Tweeting from my own app! :)"]
if (self.imageString) {
[tweetSheet addImage:[UIImage imageNamed:self.imageString]];
}
if (self.urlString) {
[tweetSheet addURL:[NSURL URLWithString:self.urlString]];
}
i checked the following tutorials/docs:
raywenderlich tutorial
(http://www.raywenderlich.com/21558/beginning-twitter-tutorial-updated-for-ios-6)
appcoda tutorial
(http://www.appcoda.com/ios-programming-101-integrate-twitter-and-facebook-sharing-in-ios-6/)
apple docs
(https://developer.apple.com/library/ios/documentation/NetworkingInternet/Reference/SLComposeViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40012205)

Load YouTube outside Application

I have a simple UIWebView showing a page including YouTube thumbnail. When I click it, it loads it inside the application, but I want it to be loaded outside application in the YouTube-app.
How can this be done?
Thanks.
It should be as simple as loading the YouTube-video-url like this:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.youtube.com/watch?v=abcde12345"]];
It won't work in the simulator because it doesn't have the YouTube-app, but it will work on the iPhone (i hope, untested).
(I also see that your accept-rate is pretty low, you should click the little ✔ next to the answer that you think is the best answer. That way people wondering about the same thing can find the most useful answer fast and the person posting the answer will be accredited.)
EDIT:
Here is an example of what you could do to catch the YouTube-urls and opening them in the YouTube-app instead of in your app:
- (BOOL)webView:(UIWebView *)wv shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
// Determine if we want the system to handle it.
NSURL *url = request.URL;
if ([url.host isEqual:#"youtube.com"] && ([url.query rangeOfString:#"watch"] != 0)) {
if ([[UIApplication sharedApplication]canOpenURL:url]) {
[[UIApplication sharedApplication]openURL:url];
return NO;
}
}
return YES;
}
This is not tested, but should work :)
From http://apiblog.youtube.com/2009/02/youtube-apis-iphone-cool-mobile-apps.html
Method 2: Embed the YouTube player in a UIWebView
No, the iPhone still doesn't do Flash, but if you haven't already
noticed, the Safari browser on the iPhone is clever enough to turn any
YouTube embed into a clickable thumbnail that launches the native
YouTube player app on the phone. You can take advantage of this
feature in your app by using a UIWebView. Here's how:
Set up a UIWebView in your app. You can make it part of a xib or create it programmatically. Size the UIWebView according to how large
you want the clickable thumbnail to be.
Grab the video url using the same method as the one described above.
Call the loadHTMLString:baseURL: method on the UIWebView instance with some carefully constructed HTML that contains the YouTube
embedded player code snippet and some supporting HTML to make sure
that the video thumbnail appears correctly. Set the base URL to the
URL of your website (it doesn't do anything here -- ordinarily
UIWebView uses it to handle relative URL links correctly).
The best way to illustrate this is with a code snippet. Note the use
of the viewport HTML meta parameter and the consistent use of width
and height parameters throughout.
// webView is a UIWebView, either initialized programmatically or
loaded as part of a xib.
NSString *htmlString = #" ";
[webView loadHTMLString:htmlString baseURL:[NSURL
URLWithString:#"http://www.your-url.com"]];
One of the biggest benefits of this approach is that your app does not
have to quit in order for the video to start playing. In fact, the
iPhone will keep your app running in the background while it fires up
the YouTube player to play the video. After the video finishes playing
(or when the user hits "Done"), the user is automatically taken back
to your app. This experience is very similar to watching embedded
YouTube videos in the iPhone Safari browser and is just as seamless.

How to obtain a copied image from the pasteboard?

I have a photo editing app where I want to provide a way for the user to edit photos from the pasteboard. For example the user might copy a photo from his website in Safari and then head over to my app and choose "Open from pasteboard". Kind of like Photoshop does it.
How can I get notified or check if there is a picture or graphic (probably a UIImage) in the pasteboard? And how could I obtain that image?
I needed one for a UIImage and this snippet helped me out.
You can always extract the image out using:
UIImage *image = [UIPasteboard generalPasteboard].image;