Video uploading issues using Facebook IOS app for other users - ios

I uploaded video from using Facebook latest sdk its works fine. I have created in ios app in Facebook developer account. Still my app in testing mode. My app was not published in app store. I have tested with my facebook account video was uploaded to my facebook account . My app status was in live. I tried with my friend account below error came all the time. Please help me how to make works with other users.
i have used code below for video uploading
NSString *filePath = [[NSBundle mainBundle] pathForResource:#"sample" ofType:#"mov"];
NSData *videoData = [NSData dataWithContentsOfFile:filePath];
NSString* videoName = [filePath lastPathComponent];
NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
[params setObject:#"testing from ios app" forKey:#"description"];
[params setObject:videoData forKey:videoName];
[FBRequestConnection startWithGraphPath:#"me/videos"
parameters:params
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error)
{
}];
In apple developer account only showing approved for email,public_profile,user_friends.
permissions:(
"public_profile"
)>, com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 200;
message = "(#200) Requires extended permission: publish_actions";
type = OAuthException;
};
};
code = 403;
}}

It means that you need request for publish_actions permission before upload. See Facebook Login for iOS, search for Checking for permissions.

Related

upload video to youtube from updated Xcode app

I have an app that I used to be able to sign into google account and then upload a video to that account. However the apps bundle ID changed and I had to update to googleSignIn.
So now when I open the view controller I want to upload the video from I have a google Sign In button which the user taps and signs in and choose to let the app have access to scopes:
googleapis.com/auth/youtube
googleapis.com/auth/youtube.upload
googleapis.com/auth/youtubepartner
googleapis.com/auth/youtube.force-ssl
I also update the apps developers key
So I now have a developers Key and a client id that I replaced from the old ones in the app for the following code
- (GTMOAuth2Authentication *)authForDailyMotion {
NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:kGDataServiceDefaultUser];
NSString *redirectURI = #"http://www.google.com/OAuthCallback";
NSString *clientID = #"552XXXXXXXX3-banchtj9877k4o4noj32eu1h5jokctu0.apps.googleusercontent.com";
NSString *clientSecret = devKey;
GTMOAuth2Authentication *auth;
auth = [GTMOAuth2Authentication authenticationWithServiceProvider:#"my little world"
tokenURL:url
redirectURI:redirectURI
clientID:clientID
clientSecret:clientSecret];
return auth;
}
After the user signs in to google they are taken to a page that shows the access the app is requesting access to
manage the youtube account
view and manage assets and associated content on Youtube
manage youtube videos
When the user currently taps the "allow" button they are taken to google.com where they can upload the video and other things from the camera roll on the device.
I want the user to be redirected back to a view within the app where the viewer can
put in a title, description, tags, choose a category, and choose its privacy and then publish the video directly from the app using
- (void)uploadVideoFile {
NSString *audioName = [pictureDictionary4 objectForKey:#"photoVideokey"];
NSArray *pathsa = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectorya = [pathsa objectAtIndex:0];
NSString *moviePath = [documentsDirectorya stringByAppendingPathComponent:#"/Movie"];
//Get a full path to the image in the documents directory.
NSString *fullPatha = [moviePath stringByAppendingPathComponent:audioName];
GDataServiceGoogleYouTube *service = [self youTubeService];
NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:kGDataServiceDefaultUser];
NSString *filename = audioName;
NSData *data = [NSData dataWithContentsOfFile:fullPatha];
GDataYouTubeMediaGroup *media = [GDataYouTubeMediaGroup mediaGroup];
[media setMediaTitle:title];
[media setMediaDescription:desc];
[media addMediaCategory:category];
[media setMediaKeywords:keywords];
NSString *mimeType = [GDataUtilities MIMETypeForFileAtPath:fullPatha
defaultMIMEType:#"video/mp4"];
GDataEntryYouTubeUpload *entry;
entry = [GDataEntryYouTubeUpload uploadEntryWithMediaGroup:media
/*fileHandle:fileHandle*/
data:data
MIMEType:mimeType
slug:filename];
GDataServiceTicket *ticket;
ticket = [service fetchEntryByInsertingEntry:entry
forFeedURL:url
delegate:self
didFinishSelector:#selector(uploadTicket:finishedWithEntry:error:)];
[self setUploadTicket:ticket];
GTMHTTPUploadFetcher *uploadFetcher = (GTMHTTPUploadFetcher *)[ticket objectFetcher];
[uploadFetcher setLocationChangeBlock:^(NSURL *url) {
[self setUploadLocationURL:url];
by tapping "publish"
I think the redirect url needs to be changed so the authentication is given to the app and then used to upload the video. However I am not sure about this
Now if the user taps the done button and goes back to the app and puts in the information described above and taps "publish"
I get the following error.
upload failed: Error Domain=com.google.HTTPStatusCode=401 *(User authentacation required)
I think this is because the authorization is only given to do the upload on line and not through the app.
Can someone tell me if I am correct in this assumption and is so how can I redirect the user back to the app to upload the video after tapping "allow"
and if I am incorrect in my assumption can someone give me some guidance on how to make this work as I want, please.
Follow this steps to get GoogleSignIn.
Here is API to upload a video to YouTube.

How to integrate Facebook/Google+ without redirect Safari browser in iOS app

I tried to integrate Facebook/Google+ in my app. I can do that by the inbuilt Facebook framework, Google Plus framework, Google open source framework, in iOS app by getting the details from the account added in settings app of the device. I can also do it by opening the Safari browser and redirect to my app after login to Facebook and Goolge+. so, I need without redirect the Safari browser.
Using new Google+ SDK, user will not have to reenter the password in safari or any browser.
Take a look on this:
https://developers.google.com/+/mobile/ios/sign-in
If the user has the native Google or Google+ mobile app installed then user will not have to re-enter their Google credentials to authorize your app.
OR
Try with GTMOAuth2ViewControllerTouch
- (id)initWithScope:(NSString *)scope
clientID:(NSString *)clientID
clientSecret:(NSString *)clientSecret
keychainItemName:(NSString *)keychainItemName
completionHandler:(GTMOAuth2ViewControllerCompletionHandler)handler
Plenty of references available online.
Google Drive iOS SDK: Display Cancel Login Button
Don't use Google-Plus, use GoogleSignIn.
Google just posted this solution:
Comment #109 on issue 900 by fa...#google.com: iOS SDK SignIn don't
leave app [Apple appstore rejection]
https://code.google.com/p/google-plus-platform/issues/detail?id=900
Hello everyone,
I’m delighted to announce an update to this issue. Today, we launched
version 2.0 of Google Sign In, featuring full built-in support for
Sign In via WebView. We hope that this update will at last remedy the
problem of App Store rejections due to use of our SDK.
Full documentation is here:
https://developers.google.com/identity/sign-in/ios
We’ve written a migration guide from G+ Sign In here:
https://developers.google.com/identity/sign-in/ios/quick-migration-guide
You can use the below code to sign in via Google+ using Webview:
Initialize UIWebview:
NSString *url = [NSString stringWithFormat:#"https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=%#&redirect_uri=%#&scope=%#",client_id,callbakc,scope];
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[webView setDelegate:self];
[self.view addSubview:webView];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
Implementation of delegate methods:
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
// [indicator startAnimating];
if ([[[request URL] host] isEqualToString:#"localhost"]) {
// Extract oauth_verifier from URL query
NSString* verifier = nil;
NSArray* urlParams = [[[request URL] query] componentsSeparatedByString:#"&"];
for (NSString* param in urlParams) {
NSArray* keyValue = [param componentsSeparatedByString:#"="];
NSString* key = [keyValue objectAtIndex:0];
if ([key isEqualToString:#"code"]) {
verifier = [keyValue objectAtIndex:1];
break;
}
}
if (verifier) {
NSString *authToken = [NSString stringWithFormat:#"code=%#&client_id=%#&client_secret=%#&redirect_uri=%#&grant_type=authorization_code", verifier,client_id,secret,callbakc];
//Use Token to Login
} else {
// ERROR!
}
[webView removeFromSuperview];
webView = nil;
return NO;
}
return YES;
}
Use Scocial.framework
https://developer.apple.com/library/ios/documentation/Social/Reference/Social_Framework/
__block ACAccount * facebookAccount;
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
NSDictionary *emailReadPermisson = #{
ACFacebookAppIdKey : #"YOUR_API_KEY",
ACFacebookPermissionsKey : #[#"email"],
ACFacebookAudienceKey : ACFacebookAudienceEveryone,
};
NSDictionary *publishWritePermisson = #{
ACFacebookAppIdKey : #"YOUR_API_KEY",
ACFacebookPermissionsKey : #[#"publish_actions"],
ACFacebookAudienceKey : ACFacebookAudienceEveryone
};
ACAccountType *facebookAccountType = [accountStore
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
//Request for Read permission
[accountStore requestAccessToAccountsWithType:facebookAccountType options:emailReadPermisson completion:^(BOOL granted, NSError *error) {if(granted){ // Enter your code}];

Video post from iOS app to Facebook is not showing up on Facebook timeline

I’ve implemented the graph API POST /me/photos in my iOS app and its working fine. Same way I implemented the /me/videos with host graph-video.facebook.com suggested in Facebook documents and this link :
[cURL - is there a way for upload a video to facebook without form?
I get success response for this too like below but the video is not showing up on my Facebook account.
{
id = 10150481253673034;
url = "https://graph-video.facebook.com/me/videos";
}
Here is the code I have written :
NSString *str=[[NSBundle mainBundle] pathForResource:#"samplevideo" ofType:#"mov"];
NSData *imageFBData = [NSData dataWithContentsOfFile:str];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
imageFBData, #"source",
#"multipart/form-data", #"Content-Type",
message, #"message",
nil];
[FBRequestConnection startWithGraphPath:#"https://graph-video.facebook.com/me/videos"
parameters:params
HTTPMethod:#"POST"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
// handle the result
NSLog(#"result : %#",result);
if(error)
NSLog(#"error : %#",error);
}];
if I use the URL as "/me/videos" like I use /me/photos instead of https://graph-video.facebook.com/me/videos, I get the below error:
{
body = {
error = {
code = 352;
message = "(#352) Sorry, the video file you selected is in a format that we don't support.";
type = OAuthException;
};
};
code = 400;
}
I tried with both .mp4 and .mov which are in supported videos. I'm sure there is no issue with video because the same video I upload to amazon S3 before posting to FB and I can play the uploaded video. Here is one sample:
https://tagg-social-staging.s3.amazonaws.com/uploads/posts/videos/36/post-video.mp4
Note: I'm not posting the video using the above URL, but as multipart /form-data
I have fixed the posting video issue using the sample code provided here:
https://developers.facebook.com/blog/post/2011/08/04/how-to--use-the-graph-api-to-upload-a-video--ios/
I don’t know how long it will work as it’s a deprecated code but I used the method ([FBRequestConnection startWithGraphPath:#"/me/videos") of latest v2.2 by changing API parameters :
“source” to “video.mov” for video
“message” to “description” for caption
Now I have one more issue:
I need to tag friends from my app. I use /{photo-id}/tags for tagging a photo which is working fine and I tried the same API to tag a video as I’m not able to get any other API from FB docs.
I get the below error for while tagging friends for a video:
{
body = {
error = {
code = 100;
message = "(#100) The parameter tag_uid is required";
type = OAuthException;
};
};
code = 400;
}
Is there any API to tag a video from mobile app?

Facebook SDK loads default image and not image from my profile, why?

I've got these facebook permissions set in my app:
NSArray *permissions = [[NSArray alloc] initWithObjects:
#"user_games_activity",
#"friends_games_activity",
#"publish_actions",
#"user_photos",
nil];
[[myDelegate facebook] authorize:permissions];
I'm making a request like so :
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:#"name,picture",#"fields",nil];
[[delegate facebook] requestWithGraphPath:#"me" andParams:params andDelegate:self];
And handling the response like :
else if([request.url rangeOfString:#"me"].location != NSNotFound)
{
NSString *username = [result objectForKey:#"name"];
NSLog(#"We think the username is %#", username);
helloGreeting.text = [NSString stringWithFormat:#"Hello %#", username];
NSString *pictureUrl = [result objectForKey:#"picture"];
NSLog(#"Now loading image [%#]", pictureUrl);
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:pictureUrl]];
profilePhoto.image = [UIImage imageWithData:data];
}
The log output I get is :
2012-06-26 15:10:49.002 FacebookIntegrator[10549:f803] We think the username is James Elsey
2012-06-26 15:10:49.003 FacebookIntegrator[10549:f803] Now loading image [http://profile.ak.fbcdn.net/static-ak/rsrc.php/v2/yo/r/UlIqmHJn-SK.gif]
Question : Why does it obtain a default generic facebook icon rather than my own profile picture? Using the same access tokens on the Graph Explorer I can get to my profile picture image URL
The documentation for user_photos states :
Provides access to the photos the user has uploaded, and photos the
user has been tagged in
User profile picture do not require user_photos permissions. Picture is likely coming from facebook cache, you should use following url for picture.
http://graph.facebook.com/<facebook id>/picture

iOS & Facebook: upload an image along with user comment to the wall

I have an app, it takes screenshot of itself and I would like to post it on user's wall along with a comment.
The problem is, I seemingly tried every option and none of it works:
[facebook dialog:#"feed" ...] doesn't work because you can supply only a URL, not a UIImage.
[facebook requestWithGraphPath ...] doesn't work because the user is not prompted for the comment.
I could first (silently) try to upload the screenshot with requestWithGraphPath and then feed its newly created URL to dialog which doesn't work because of "FBCDN image is not allowed in stream". All of this is of course using callbacks which, including login callback, makes for nice big mess.
I even tried ShareKit but forgot about it after the app strangely could/couldn't login.
Please, how can I share both an image and a comment?
If you are using facebook's latest iOS SDK, in Hackbook sample app, look for APICallsViewController.m file. There is this method that you can post using UIImage directly:
/*
* Graph API: Upload a photo. By default, when using me/photos the photo is uploaded
* to the application album which is automatically created if it does not exist.
*/
- (void) apiGraphUserPhotosPost {
NSString *sourcePath = [[NSBundle mainBundle] resourcePath];
NSString *file1 = [sourcePath stringByAppendingPathComponent:#"/MP1101frame1002.jpg"];
UIImage *img = [[[UIImage alloc]initWithContentsOfFile:file1]autorelease];
[self showActivityIndicator];
currentAPICall = kAPIGraphUserPhotosPost;
HackbookAppDelegate *delegate = (HackbookAppDelegate *) [[UIApplication sharedApplication] delegate];
// Download a sample photo
NSURL *url = [NSURL URLWithString:#"http://www.facebook.com/images/devsite/iphone_connect_btn.jpg"];
NSData *data = [NSData dataWithContentsOfURL:url];
// UIImage *img = [[UIImage alloc] initWithData:data]; //here you can insert your UIImage
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
yourMessageHere, #"message", //whatever message goes here
img, #"picture", //img is your UIImage
nil];
[[delegate facebook] requestWithGraphPath:#"me/photos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
}
If you haven't already, you may want to try the latest development branch of ShareKit at this address:
https://github.com/Sharekit/Sharekit
It has significant improvements added by the community over the canonical version.

Resources