Share text on Tumblr from ios application - iphone

In my application I want to share text via tumblr api.
I just want some hint on this so I can get exact idea on how to share text on tumblr.
Thanks

You can can use https://github.com/tumblr/TMTumblrSDK#authentication
i have shared text to tumblr with below code
NSArray* paramsKeys = [[NSArray alloc] initWithObjects:
#"title",
#"body",
nil];
NSArray* paramsVals = [[NSArray alloc] initWithObjects:
#"Testing",
#"HEllo Posting it to Tumblr",
nil];
NSDictionary *paramsDict = [[NSDictionary alloc]initWithObjects:paramsVals forKeys:paramsKeys];
[[TMAPIClient sharedInstance]text:#"blogname" parameters:paramsDict callback:^(id response, NSError *error)
{
if(!error)
{
NSDictionary *dashboard = response;
NSLog(#"%#",dashboard);
}
}];

Related

iOS Facebook SDK 3.2 Image Publish w/Description Open Graph

No matter what I try I cannot get my description to show up on Facebook. I used the debugger and all is well with the generated link and the URL is populated with the appropriate data. The picture is uploaded fine, but the description is not there. Is there something I need to setup in Facebook settings for the app?
Here is the relevant code:
- (id<FBPost>)outfitObjectForOutfit{
id<FBPost> result = (id<FBPost>)[FBGraphObject graphObject];
NSString *format =
#"http://mysite.mobi/app/fbOpen.php?"
#"og:title=%#&og:description=%%22%#%%22&"
#"og:caption=%%22%#%%22&"
#"og:image=http://mysite.mobi/images/transBlank.png&"
#"body=%#";
result.url = [NSString stringWithFormat:format,
#"New Post Title",fldDescription.text,fldDescription.text,fldDescription.text];
return result;
}
And the portion that publishes to FB:
- (void)postOpenGraphActionWithPhotoURL:(NSString*)photoURL
{
id<FBPost> outfitObject = [self outfitObjectForOutfit];
id<FBPostOutfit> action =
(id<FBPostOutfit>)[FBGraphObject graphObject];
action.outfit=outfitObject;
if (photoURL) {
NSMutableDictionary *image = [[NSMutableDictionary alloc] init];
[image setObject:photoURL forKey:#"url"];
NSMutableArray *images = [[NSMutableArray alloc] init];
[images addObject:image];
action.image = images;
}
[FBSettings setLoggingBehavior:[NSSet
setWithObjects:FBLoggingBehaviorFBRequests,
FBLoggingBehaviorFBURLConnections,
nil]];
NSLog(#"%#",action);
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:fldDescription.text forKey:#"message"];
[FBRequestConnection startForPostWithGraphPath:#"me/appnamespace:action"
graphObject:action
completionHandler:
^(FBRequestConnection *connection, id result, NSError *error) {
NSString *alertText;
if (!error) {
alertText = [NSString stringWithFormat:
#"Posted Open Graph action, id: %#",
[result objectForKey:#"id"]];
} else {
alertText = [NSString stringWithFormat:
#"error: domain = %#, code = %d",
error.domain, error.code];
NSLog(#"%#",error);
}
[[[UIAlertView alloc] initWithTitle:#"Result"
message:alertText
delegate:nil
cancelButtonTitle:#"Thanks!"
otherButtonTitles:nil]
show];
}
];
}
I figured out my problem. I was confusing what the Facebook examples did (activity publishing) with publishing to a user's wall. This was all that I had to do to get it to work:
NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
[params setObject:fldDescription.text forKey:#"message"];
[params setObject:UIImagePNGRepresentation(userImage) forKey:#"picture"];
[FBRequestConnection startWithGraphPath:#"me/photos"
parameters:params
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error)
{
if (error) {
[[[UIAlertView alloc] initWithTitle:#"Result"
message:#"Sorry there was an error posting to Facebook."
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil]
show];
}
}];
I should also mention that I had to go into the opengraph settings for my app and allow user messages and user generated photos.

sharing text on "facebook Page" in ios from our app

I have a Facebook page, and i want to share some text on that page just like my status as we share on our "me/feed" from our application.
Please someone suggest how i should go about it?
for iOS 6.0 you can do something like that:
NSString *text1 = [NSString stringWithFormat:#"%# %#", NSLocalizedString(#"Check out this nice'... ", #""), self.title];
NSString *text2 = [NSString stringWithFormat:#"%# %#", NSLocalizedString(#"in", #""), self.restaurant.title];
NSString *text3 = NSLocalizedString(#"Sent from FoodRock Menus App", #"");
NSURL *appURL = [NSURL URLWithString:#"http://testappstorelink.com"];
NSArray *activityItems = [NSArray arrayWithObjects:text1, text2, text3, appURL, photo, nil];
UIActivityViewController *actVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems
applicationActivities:nil];
actVC.excludedActivityTypes = [NSArray arrayWithObjects:UIActivityTypeAssignToContact, UIActivityTypeCopyToPasteboard,
UIActivityTypePrint, UIActivityTypeSaveToCameraRoll, nil];
actVC.completionHandler = ^(NSString *activityType, BOOL completed){
DLog(#"ACTIVITYTYPE: %# FINISHED: %#", activityType, completed ? #"YES" : #"NO");
if (completed) {
NSString *socialString = #"";
if ([activityType containsSubstring:#"PostToTwitter"]) {
socialString = #"Twitter";
} else if ([activityType containsSubstring:#"PostToFacebook"]) {
socialString = #"Facebook";
} else if ([activityType containsSubstring:#"Message"]) {
socialString = #"Message";
} else if ([activityType containsSubstring:#"Mail"]) {
socialString = #"Mail";
}
[[FRNWAchievementsController controller] reportSocialShareEvent:socialString menuItem:self];
}
};
return actVC;
Here are some code snippets to help you out, but you should also have a look at the Facebook developer examples which are pretty good.
// To log in to Facebook with permission to post...
m_Facebook = [[Facebook alloc] initWithAppId:YOUR_FACEBOOK_APPID
andDelegate:self];
m_FacebookPermissions = [[NSArray
arrayWithObjects:/*#"read_stream",*/ #"publish_stream", nil] retain];
[m_Facebook authorize:m_FacebookPermissions];
And in some other method after the fbDidLogin callback tells you you're logged in:
// After successful login…
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
WHAT_YOU_WANT_TO_SAY, #"message",
nil];
[m_Facebook requestWithGraphPath:#"/me/feed"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];

facebook upload photo along with description and caption in iphone

I want to upload the image to the facebook.
I could upload the photo along with caption. I also want to upload the description
I tried adding the key "description" to the dictionary. But it didn't work.
Is it possible to upload the description as well?
Following is the code i am using..
- (void)postToWall {
FBRequest *uploadPhotoRequest = [FBRequest request];
NSData* imageData = UIImageJPEGRepresentation(saveImage, 1.0);
UIImage *image_ = [[UIImage alloc] initWithData:imageData];
FBPermissionDialog* dialog1 = [[[FBPermissionDialog alloc] init] autorelease];
dialog1.delegate = self;
dialog1.permission = #"photo_upload";
[dialog1 show];
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Hey!!!!!!", #"caption",
#"I Own It..", #"description", //This didn't post the description..
nil];
if (nil!=image_)
[uploadPhotoRequest call:#"photos.upload" params:params dataParam:(NSData*)image_];
NSLog(#"image uploaded");
[image_ release];
}
Have a look at this
http://www.raywenderlich.com/1488/how-to-use-facebooks-new-graph-api-from-your-iphone-app

How to post a photos on facebook through iPhone app?

I am trying to post image on facebook but not successful yet,
my codes are:
- (void)postToWall{
int im = 1;
NSData *myimgData;
myimgData = [NSData dataWithContentsOfFile:saveImagePath];
//pstimg = myimgData;
NSArray *chunks = [pstimg componentsSeparatedByString: #"."];
NSString *atch= [chunks objectAtIndex: 0];
NSString *filePath = [[NSBundle mainBundle] pathForResource:atch ofType:#"jpg"];
img = [[UIImage alloc] initWithContentsOfFile:filePath];
//start
FBDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
NSString *str = #"Hello";
str = [str stringByReplacingOccurrencesOfString:#" " withString:#"+"];
dialog.cMessage=str;
dialog.userMessagePrompt = #"Enter your message:";
[dialog show];
NSData * findata;
//edited from here
if(im==1)
{
findata = myimgData;
}
else
{
findata = (NSData *)img;
}
NSMutableDictionary * param = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, #"picture",
nil];
FBRequest *uploadPhotoRequest =[FBRequest requestWithDelegate:self] ;
[uploadPhotoRequest call:#"facebook.photos.upload" params:param dataParam:myimgData];
[img release];
}
But it not posted.
To post a photo on Facebook you need to use the iOS SDK from Facebook:
https://github.com/facebook/facebook-ios-sdk
There you'll find sample app with authentication and much more, like posting a photo.

How to send text and images using Facebook API in iPhone SDK?

In my iPhone app, I want to send text as well as images to facebook.
Currently the facebook API suggest that there are seperate user permissions that enable us to do so.
Is there a way out where in I can do both using only one API in my project?
If Yes, How can we do so?
References to any articles or tutorials would be very helpful
Please Help & Suggest.
Thanks
Yes you can do this.
Please have a look at all the methods as below:
- (IBAction)uploadPhoto:(id)sender {
[self postOnFacebook];
}
//Post Message and Photo on Facebook Function
-(void)postOnFacebook
{
NSString *strPostMessage = [self createMessageForPostOnFacebook:74.112 withLongitude:21.85];
//UIImage *img = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:objClsProductSearch.strProductImageURL]]];
//UIImage *img = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:#"http://www.facebook.com/images/devsite/iphone_connect_btn.jpg"]]];
UIImage *img = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:#"http://d1xzuxjlafny7l.cloudfront.net/wp-content/uploads/2011/08/HUDTutorial.jpg"]]];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
strPostMessage,#"message",img, #"source",
nil];
[_facebook requestWithGraphPath:#"/me/photos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
[img release];
}
//Create Message for posting on Facebook
-(NSString *)createMessageForPostOnFacebook:(double)pfltLatitude withLongitude:(double)pfltLongitude
{
//NSString *urlString = [NSString stringWithFormat:#"http://maps.google.com/maps/geo?q=%f,%f&output=csv",pfltLatitude, pfltLongitude];
//NSString *urlString = [NSString stringWithFormat:#"http://maps.google.com/maps/geo?q=%f,%f&output=csv",#"", #""];
//NSError* error;
//NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString] encoding:NSASCIIStringEncoding error:&error];
//NSArray *listItems = [locationString componentsSeparatedByString:#","];
NSString *strMessage = nil;
/*if([[listItems objectAtIndex:0] isEqualToString:#"200"])
{
strMessage = [NSString stringWithFormat:#"I found a %# using BH for iPhone \n Location : %# \n Latitude : %f & Longitude : %f \n Product Rating : %d",objClsProductSearch.strCategoryname,[locationString substringFromIndex:6],appDelegate.dblLatitude,appDelegate.dblLongitude,btnTmp.tag];
}*/
strMessage = [NSString stringWithFormat:#"I found a %# using BH for iPhone \n Location : %# \n Latitude : %f & Longitude : %f \n Product Rating : %d", #"Cat Name", #"Location", 74.112, 21.85, 1];
return strMessage;
}
I hope you will have success using the above code.
Let me know in case of any difficulty.
In you app delegate, have a look at below methods whether it is implemented or not.
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
//return [[controller facebook] handleOpenURL:url];
//return [[objPage2ViewController facebook] handleOpenURL:url];
return [[[self.navigationController topViewController] facebook] handleOpenURL:url];
}
Cheers
I'm not sure that it is possible. I've post image with next solution:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
takedPhoto, #"picture",
#"some text", #"message",
nil];
[facebook requestWithGraphPath:#"/me/photos" andParams:params
andHttpMethod:#"POST" andDelegate:self];
takedPhoto is UIImage.
But it is only loading photos in photo album (and approve it if you allow permissions when logging in).
I don't know how can I post message on wall with this uploaded image...
Regards,