How to post video on twitter in iPhone sdk - iphone

I am an ios developer,i am working on app in which i needs to send video on twitter.But i searched and found that we can only post link of Video,but cannot post the video itself in iPhone sdk.
Can anyone suggest me what to do,if i need to post video on twitter.

You can use TWRequest class with
- (void)addMultiPartData:(NSData *)data withName:(NSString *)name type:(NSString *)type
I am not sure if uploading video is possible.
More on using TWRequest https://dev.twitter.com/docs/ios/posting-images-using-twrequest

I just suggest you to look over the TwitVid documentation From bellow link:
http://twitvid.pbworks.com/w/page/22556295/FrontPage
UPDATE:
i use this type of logic in 4.3 with shareKit
NSString *urlstr =[YorURL stringByReplacingOccurrencesOfString:#" " withString:#""];
[urlstr retain];
NSString *apiEndpoint = [NSString stringWithFormat:#"http://tinyurl.com/api-create.php?url=%#",urlstr];
[apiEndpoint retain];
NSLog(#"\n\n APIEndPoint : %#",apiEndpoint);
NSString *shortURL = [NSString stringWithContentsOfURL:[NSURL URLWithString:apiEndpoint]
encoding:NSASCIIStringEncoding
error:nil];
[shortURL retain];
NSLog(#"Long: %# - Short: %#",urlstr,shortURL);
NSString *txtShare=[NSString stringWithFormat:#"You watching Your %#",shortURL];
SHKItem *item = [SHKItem text:txtShare];
[SHK setRootViewController:self];
[SHKTwitter shareItem:item];
hope this help you...

Thanks to the uploading media new API, you can share video to twitter. And I have tried it, it works.
Please check this: https://github.com/liu044100/SocialVideoHelper
You just need to call this class method.
+(void)uploadTwitterVideo:(NSData*)videoData account:(ACAccount*)account withCompletion:(dispatch_block_t)completion;
Hope it can resolve your problem.

Related

Get Facebook profile pic using 3.0 SDK

I'm having trouble getting the user's profile pic with the new Facebook SDK. All the answers on here use methods from the old SDK that no longer work.
I've tried using the FBProfilePictureView recommended in Facebook's tutorial, but this picture doesn't get cached and I don't think it can be converted into a UIImage.
Can anyone please provide some help? Thanks!
OK, I finally got this using the following:
imageData = [[NSMutableData alloc] init]; // the image will be loaded in here
NSString *urlString = [NSString stringWithFormat:#"http://graph.facebook.com/%#/picture?type=large", user.id];
NSMutableURLRequest *urlRequest =
[NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:2];
// Run request asynchronously
NSURLConnection *urlConnection = [[NSURLConnection alloc] initWithRequest:urlRequest
delegate:self];
if (!urlConnection)
NSLog(#"Failed to download picture");
Then I used -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data and -(void)connectionDidFinishLoading:(NSURLConnection *)connection to put the image together.
Best solution i've found:
I've used UIImage from AFNetworking https://github.com/AFNetworking/AFNetworking. It handles redirect and caching so you can fetch profile picture for every user id you have.
NSString *imageUrl = [NSString stringWithFormat:#"http://graph.facebook.com/%#/picture", ((NSDictionary<FBGraphUser> *) [self.friends objectAtIndex: indexPath.row]).id];
[friendCell.imageView setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:[UIImage imageNamed:#"profile.jpg"]];
Use https://github.com/rs/SDWebImage to cache the image. The URL to request the image should be
NSString *string = [NSString stringWithFormat:#"https://graph.facebook.com/%#?fields=picture", userid];
Use the link:
https://graph.facebook.com/me?fields=picture
to get the current user's profile picture.
Facebook provides the Graph API explorer tool which can come in handy when you want to try queries or to check the returned output.
Here's a link to the User API Reference.
If your problem is related to "self.userPofilePicture.profileID = user.id;".
Then self.userProfilePicture return UIView so just take View and display in it.
Don't forgot add class FBProfilePictureView in Identity Inspector as well as [FBProfilePictureView class] to AppDelegate implementation file.
I hope this will helpful.

How to post an images on Google Plus in an iOS Application

I successfully posted content and (Links)URL using Google Plus API in iphone.
Using Following code:
googleShare =[[[GooglePlusShare alloc] initWithClientID:#"my key"] autorelease];
[googleShare setDelegate:self];
appDelegate.shareGOOGLe =googleShare;
NSString *inputURL = #"";
NSURL *urlToShare = [inputURL length] ? [NSURL URLWithString:inputURL] : nil;
NSLog(#"%#",urlToShare);
NSString *inputText = #"TEst Sharing testing from iOS 5.0";
NSString *text = [inputText length] ? inputText : nil;
NSLog(#"%#",text);
[[[[googleShare shareDialog]
setURLToShare:urlToShare]
setPrefillText:shareMessge] open];
But I want to post images to google plus.
Can any one help me?
Thanks in advance.
It is currently not possible to share images on Google+ with the Google+ iOS SDK.
This is possible to share a Image with google plus
- (IBAction) didTapShare: (id)sender {
id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
[shareBuilder attachImage:[UIImage imageNamed:#"yourImagename.png"]];
[shareBuilder open];
}
Referenced from https://developers.google.com/+/mobile/ios/share/
#Chirag... You should see Flipboard application for iPhone/iPad. It shares the link,comment and Image on Google+ account. Please take a look and let me know if i am wrong at any point.
These are the links will help:
Link Shows how and what can be shared.
https://developers.google.com/+/mobile/ios/share/
at the bottome of link 1, it mentions "Attaching media to your shared posts. You can attach pictures and movies to your posts for your users to share to their stream."
https://developers.google.com/+/mobile/ios/share/media
Link 2 shows the code snippet to share the media ; images and videos
Following is the Code snippet to share Image on google+
- (IBAction) didTapShare: (id)sender {
id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
// Set any prefilled text that you might want to suggest
[shareBuilder setPrefillText:#"Achievement unlocked! I just scored 99 points. Can you beat me?"]
NSString *fileName = #"samplemedia1";
[shareBuilder attachImage:[UIImage imageNamed:fileName];
[shareBuilder open];
}

How to integrate bitly api to shorten my link in iphone sdk

I created an app which get the url of my youtube videos in the text field using GData Client Library. Now i want to shorten that url using bitly api.. But i don't have an idea about that.
if anybody done it before me, please tell me how you did it.
Thanks,
Chakradhar.
This is a quick and easy way of doing it.
You will need to register with bit.ly and obtain a login name and API key.
NSString *username = #"user";
NSString *apiKey = #"R_11111111111111";
NSString *url = #"yoururl.com";
NSString *shortURL = [NSString stringWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:#"http://api.bit.ly/v3/shorten?login=%#&apikey=%#&longUrl=%#&format=txt", username, apiKey, url]] encoding:NSUTF8StringEncoding error:nil];
Here is an iOS wrapper for bit.ly api https://github.com/st3fan/iphone-bitly
This has worked well for me, and since it is a synchroeous request there is a slight delay to fetch the link so you may want to display a Progress HUD:
NSString *accessToken = YOUR_ACCESS_TOKEN;
NSString *url = YOUR_URL;
NSString *bitlyRequest = [NSString stringWithFormat:#"https://api-ssl.bitly.com/v3/shorten?access_token=%#&longUrl=%#",accessToken, url];
NSString *bitlyResponse = [NSString stringWithContentsOfURL:[NSURL URLWithString:bitlyRequest] encoding:NSUTF8StringEncoding error:nil];
NSData *data = [bitlyResponse dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *bitlyDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSString *bitlyUrl = bitlyDictionary[#"data"][#"url"];
I suggest you start with theri API documentation.

adding photo on facebook wall

- (void)postToWall {
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = [NSString stringWithFormat: subjectTitle]; //subjectTitle works here but not as name where i need it.
NSString *src = #"http://www.sample.com/image.png";
NSString *name = storyLink; //<---------------------------------works with storyLink but not subjectTitle. I need subjectTitle to work here
NSString *href = storyLink;
NSString *attachment = [NSString stringWithFormat:#"{\"name\":\"%#\",\"media\":[{\"type\":\"image\", \"src\":\"%#\", \"href\":\"%#\"}]}", name, src, href];
dialog.attachment = attachment;
[dialog show];
}
i want to add image from photo library instred of http://www.sample.com/image.png to the facebook wall.
can anyone provides me help ....
Thanks in advance ......
You can access the URL's of the iPhoto library items using the UIImagePickerController and its delegate method.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
When the user picks a photo the URL will be in the dictionary under the key UIImagePickerControllerMediaURL
Probably this Stack Overflow Question about uploading images to Facebook might help you.
Also Sharekit is a nice framework to add Social features to you iPhone App. I think it has facility to share images. You can check it out at Sharekit official website.

How to call itunes from my iphone app with search for a known CD

here is my code:
-(IBAction)itunesBuy:(id)sender{
// NSString *urlString = [[NSString alloc] initWithFormat:#"http://itunes.com/%#/%#", self.artistTerm,self.titleTerm];
NSString *urlString = [[NSString alloc] initWithFormat:#"http://phobos.apple.com/WebObjects/MZSearch.woa/wa/advancedSearchResults?albumTerm=%#", self.titleTerm];
NSLog(#"urlString=%#", urlString);
NSString *escapedValue = [(NSString *)CFURLCreateStringByAddingPercentEscapes(nil,(CFStringRef)urlString,NULL,NULL,kCFStringEncodingUTF8) autorelease];
NSURL *itunesUrl = [NSURL URLWithString:escapedValue];
if (![[UIApplication sharedApplication] openURL:itunesUrl])
NSLog(#"%#%#",#"Failed to open url:",[itunesUrl description]);
}
You can see that I tried the simpler itunes link as well. My understanding was that this won't work on the simulator, but should on the device.
On my iPad and my iPhone, it launches itunes, but then I get an error saying:"Your request could not be completed. This search cannot be performed on this device."
Any help would be appreciated.
Steve
There is no advanced search in device appstore, only in itunes on your Mac/PC.
Try to use the simple search with "itms://phobos.apple.com/WebObjects/MZSearch.woa/wa/search?term=%#".