I am using sharekit to upload the image on twitter.
I have set keys and callback URL perfectly.
But after entering my login and password credentials
to upload image on twitter I got following error message.
"There was a problem requesting access from Twitter."
Earlier before few months in the same app I was able to upload
the image with same code.
But right now I am facing the problem
can you tell me what is the exact problem
thanks in advance.
There is some changes occur in share kit. To resolve this issue. You have to change some piece of lines in SHKTwitter.mfile under this method:
- (void)tokenAccessModifyRequest:(OAMutableURLRequest *)oRequest
For detail info follow this link & make changes according to this link & then check:
https://github.com/SteveLeviathan/ShareKit/commit/7aab77655c1cbb1bf79092fcb3bb24dd80ab6380
UPDATE:
Replace your this method with my & then check:
- (void)tokenAccessModifyRequest:(OAMutableURLRequest *)oRequest
{
if (xAuth)
{
NSDictionary *formValues = [pendingForm formValues];
OARequestParameter *username = [[[OARequestParameter alloc] initWithName:#"x_auth_username"
value:[formValues objectForKey:#"username"]] autorelease];
OARequestParameter *password = [[[OARequestParameter alloc] initWithName:#"x_auth_password"
value:[formValues objectForKey:#"password"]] autorelease];
OARequestParameter *mode = [[[OARequestParameter alloc] initWithName:#"x_auth_mode"
value:#"client_auth"] autorelease];
[oRequest setParameters:[NSArray arrayWithObjects:username, password, mode, nil]];
}
else {
if (self.pendingAction == SHKPendingRefreshToken)
{
if (accessToken.sessionHandle != nil)
[oRequest setOAuthParameterName:#"oauth_session_handle" withValue:accessToken.sessionHandle];
}
else
[oRequest setOAuthParameterName:#"oauth_verifier" withValue:[authorizeResponseQueryVars objectForKey:#"oauth_verifier"]];
}
}
You can switch to ShareKit 2 - it is being updated frequently.
Related
I am trying to share my app document (file url ) using UIActivityViewController. When activityviewcontroller pop up (testing on iPad device), I get only iMessage and Mail options. I DO NOT GET OTHER OPTIONS like Facebook, Twitter, Copy, Print, etc. Why? Please help me. I need Facebook, twitter options also. File type which I am sharing using NSURL is .txt
Note: I am already signed in to my Facebook, twitter account in iOS settings.
Source code which I am using:
NSURL *url = [NSURL fileURLWithPath:self.path];
NSArray *objectsToShare = #[url];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
[APP_VIEW_CONTROLLER presentViewController:activityViewController animated:YES completion:nil];
}
else
{
if (![self.activityPopover isPopoverVisible]) {
self.activityPopover = [[UIPopoverController alloc] initWithContentViewController:activityViewController];
[self.activityPopover presentPopoverFromRect:pathViewController.pathViewWrapper.pathView.bounds inView:pathViewController.pathViewWrapper.pathView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
else
{
//Dismiss if the button is tapped while pop over is visible
[self.activityPopover dismissPopoverAnimated:YES];
}
}
It is indeed mysterious what shows up in the UIActivityViewController. Regarding Facebook and Twitter 1) it likely needs to be an http or https URL (not a file URL), 2) make sure those services are configured on the simulator or iOS device you're using.
For posting to Facebook. The file can be a file stored on the device locally. However, it needs to be converted to MP4. By default, videos taken by device camera are .MOV files. Once you convert to .MP4 if you provide the local file location, UIActivityController will share to Facebook.
I got FB to work, I'm working on Twitter now. I will edit my answer and provide details when I'm done.
Here is some code:
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:activities];
activityController.excludedActivityTypes = #[ UIActivityTypeMail,
UIActivityTypeAssignToContact,
UIActivityTypePrint,
UIActivityTypeCopyToPasteboard,
UIActivityTypeAddToReadingList,
UIActivityTypeSaveToCameraRoll];
NSMutableArray *items = [[[Engine sharedEngine].thingsManager getSharingMessageForThingWithId:self.thingId
categoryName:self.category.name
brandName:self.brand.name
andText:message
isVideo:([self.videoURL.absoluteString length] > 0 ? YES : NO)] mutableCopy];
if ([self.videoURL.absoluteString length] > 0) {
//Get the .mp4 converted video url
if (self.awsManager == nil) {
self.awsManager = [[AWSManager alloc] init];
}
NSURL *mp4Url = [self.awsManager convertVideoToMP4:self.videoURL];
//[items addObject:self.videoAmazonPath];
[items addObject:mp4Url];
} else {
[items addObject:self.image];
}
Hope this helps.
I want to implement location check-in feature in ios. My application is using google+ ios sdk. The problem which I am facing is that after I have implemented google+ check-in feature then that post is not being displayed on my google+ account.
The technique which I have tried and implemented is written below.
-(IBAction)checkIn
{
GTMOAuth2Authentication *auth = [GPPSignIn sharedInstance].authentication;
GTLServicePlus* plusService = [[GTLServicePlus alloc] init] ;
plusService.retryEnabled = YES;
[plusService setAuthorizer:auth];
GTLPlusMoment *moment = [[GTLPlusMoment alloc] init];
moment.type = #"http://schemas.google.com/CheckInActivity";
GTLPlusItemScope *target = [[GTLPlusItemScope alloc] init] ;
target.url =#"https://developers.google.com/+/plugins/snippet/examples/place";
moment.target = target;
GTLQueryPlus *query =
[GTLQueryPlus queryForMomentsInsertWithObject:moment
userId:#"me"
collection:kGTLPlusCollectionVault];
[plusService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
id object,
NSError *error) {
if (error) {
GTMLoggerError(#"Error: %#", error);
NSString *failure =
[NSString stringWithFormat:#"Status: Error: %#", error];
NSLog(#"%#",failure);
} else {
NSString *result = #"CheckedIn Saved in Google+";
NSLog(#"%#",result);
}
}];
}
Can any one please help me out. Is this the right way of implementing location check-in feature of google+ or is there any other method for it?
The method you're using is writing an "app activity" to Google+, which stores a "moment" in the user's app activity vault. As noted on https://developers.google.com/+/mobile/ios/app-activities these moments are not directly visible on the user's stream, although users may choose to share them to the stream if they wish.
To see the moments that have been shared, you will need to use the desktop app. Your profile has a list of apps that are using the Google+ Sign-In and you can view, share, and delete the activities for each of these apps. The mobile Google+ clients don't let you view the activities yet.
I'm working on using the ObjectiveFlickr library to upload photos to Flickr from my iPhone app. I am able to authorize the app and perform general requests, but I am getting an error while trying to upload a photo. The photo is meant to be uploaded is an image captured using AVFoundation. Here is the relevant code:
UIImage *image = [[UIImage alloc] initWithData:imageData];
if ([[AppDelegate sharedDelegate].apiContext.OAuthToken length]) {
NSData *uploadData = UIImageJPEGRepresentation(image, 1);
if (!flickrRequest) {
flickrRequest = [[OFFlickrAPIRequest alloc] initWithAPIContext:[AppDelegate sharedDelegate].apiContext];
flickrRequest.delegate = self;
flickrRequest.requestTimeoutInterval = 60.0;
}
[flickrRequest uploadImageStream:[NSInputStream inputStreamWithData:uploadData] suggestedFilename:#"Test" MIMEType:#"image/jpeg" arguments:[NSDictionary dictionaryWithObjectsAndKeys:#"0", #"is_public", nil]];
[UIApplication sharedApplication].idleTimerDisabled = YES;
NSLog(#"Can upload photo");
The flickrRequest object is defined and #property'd in the .h file pertaining to the code above.
The OFFlickrRequestDelegate methods are as follows:
- (void)flickrAPIRequest:(OFFlickrAPIRequest *)inRequest imageUploadSentBytes:(NSUInteger)inSentBytes totalBytes:(NSUInteger)inTotalBytes {
NSLog(#"Success");
}
- (void)flickrAPIRequest:(OFFlickrAPIRequest *)inRequest didCompleteWithResponse:(NSDictionary *)inResponseDictionary {
NSLog(#"%s %# %#", __PRETTY_FUNCTION__, inRequest.sessionInfo, inResponseDictionary);
}
- (void)flickrAPIRequest:(OFFlickrAPIRequest *)inRequest didFailWithError:(NSError *)inError {
NSLog(#"%s %# %#", __PRETTY_FUNCTION__, inRequest.sessionInfo, inError);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:[inError description] delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
}
When I run the project on the device the console shows:
Can upload photo
Success
Success
Success
Success
flickrAPIRequest:didFailWithError:(null) Error Domain=org.lukhnos.ObjectiveFlickr Code=2147418115 "The operation couldn’t be completed. (org.lukhnos.ObjectiveFlickr error 2147418115.)"
Searching through the API's documentation, "error 2147418115" is defined as "OFFlickrAPIRequestFaultyXMLResponseError". I'm not really sure what this means though. Also strange--"Success" appears four times when I'm only attempting to upload one photo.
The sample app utilizing ObjectiveFlickr, "Snap and Run" uploads photos fine on the same device that I am testing on. Comparing the code between my app and Snap and Run, I don't see any major differences that could cause the photo not to upload.
Any help would be greatly appreciated.
That is strange. OFFlickrAPIRequestFaultyXMLResponseError means the returned data cannot be parsed as XML. If the sample app SnapAndRun runs correctly and yours don't, I suggest add one line in ObjectiveFlickr.m, right after the line NSString *stat = [rsp objectForKey:#"stat"];:
NSString *dataString = [[[NSString alloc] initWithData:[request receivedData] encoding:NSUTF8StringEncoding] autorelease];
NSLog(#"received response: %#", dataString);
This may help you find out what goes wrong (e.g. if it's a server-side issue, or some response format that the library missed).
When I got this error I used Charles to see what was going on. Flickr was sending back an error saying that the signature was invalid. Looking at my request, I found that I had reversed the order of the key and values (i.e. there was whitespace in one of my keys, which probably caused a signature error).
No Matter what i do, i cannot get a post published to an application page wall (the app being logged into) via an iPhone application. I'm able to log in using FBLoginDialog and then retrieve data to populate a tableview, however when i click a button to publish some test content it doesn't work. Here is the button action:
- (void)compose:(id)sender;
{
NSString *tid=#"115372005166292";
NSString *body = #"My Test";
NSArray *obj = [NSArray arrayWithObjects:body,[NSString stringWithFormat:#"%#", tid],nil];
NSArray *keys = [NSArray arrayWithObjects:#"message",#"target_id",nil];
NSDictionary *params = [NSDictionary dictionaryWithObjects:obj forKeys:keys];
[[FBRequest requestWithDelegate:self] call:#"facebook.stream.publish" params:params];
}
I have also used the FBStreamDialog which works, however i'm faced with two issues there. The dialog lacks customization and i'm unable to handle the callback when the item is posted (e.g. reload the tableview)
I've been searching the internet and all of the examples are similar to the code above, so i'm not sure what i could be missing.
Thanks
You need to ask for extended permissions. After login show this:
FBPermissionDialog* dialog = [[[FBPermissionDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.permission = #"status_update";
[dialog show];
Doc: http://github.com/facebook/facebook-iphone-sdk/#readme
I found out how to send some text on the user's wall, with the FBConnect API, on iphone.
I even found how to put an image already on the internet :
FBFeedDialog* dialog = [[[FBFeedDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.templateBundleId = 12345;
dialog.templateData = #"{\"image\":[{\"src\":\"http://sample.png\",\"href\":\"http://sample.com\"}] }";
[dialog show];
(see http://wiki.developers.facebook.com/index.php/Facebook_Connect_for_iPhone)
But I can't figure out how to upload an UIImage from my iphone to the user's wall with FB Api.
Do I have, first, to upload the image on any website, then put its url in the templateData ?
Isn't there any simpler solution ?
Thanks.
Martin
Use the below function to upload the image, pass the UIImage as the parameter, it will work.
- (void)uploadPhoto:(UIImage *)uploadImage
{
NSMutableDictionary *args = [[[NSMutableDictionary alloc] init] autorelease];
[args setObject:uploadImage forKey:#"image"]; // 'images' is an array of 'UIImage' objects
[args setObject:#"4865751097970555873" forKey:#"aid"];// this should be album id
uploadPhotoRequest = [FBRequest requestWithDelegate:self];
[uploadPhotoRequest call:#"photos.upload" params:args];
NSLog(#"uploading image is successful");
}
[[FBRequest requestWithDelegate:self] call:#"facebook.photos.upload" params:params dataParam:(NSData*)img;
and pass params to nil . it will upload image to default album