Facebook video Upload error - iphone

Facebook video upload error: i'm using the combination of the old
and the new API/SDK from the link https://github.com/zoul/facebook-ios-sdk/commit/efb4b44fad333f8daa70a517bb5328b9352320df
and i m getting session id properly in the video Upload class
- (void) startUploadWithURL: (NSURL*) movieURL params: (NSDictionary*) userParams delegate: (id ) delegate
{
apiKey = #"5c009deec3b253bef6fe6cdd97e86b3f";
appSecret = #"218421681dfb46043bed3dd25a03bbce";
if ([self sessionID] == nil) {
NSLog(#"Unable to retrieve session key from the access token.");
return;
}
printf(" \n\n session id == %s",[[self sessionID] UTF8String]);
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:userParams];
[params setObject:#"1.0" forKey:#"v"];
[params setObject:#"facebook.video.upload" forKey:#"method"];
[params setObject:[self sessionID] forKey:#"session_key"];
[params setObject:apiKey forKey:#"api_key"];
[params setObject:[self signatureForParams:params] forKey:#"sig"];
[params setObject:[NSData dataWithContentsOfURL:movieURL] forKey:[movieURL lastPathComponent]];
[[FBRequest getRequestWithParams:params httpMethod:#"POST" delegate:delegate requestURL:kAPIURL] connect];
}
its returning the wrong result and not uploading video to the Facebook

Without using graph api you can upload videos to facebook.login facebook and go to this link. there you will get a id like xyz#m.facebook.com .just mail your videos to this mail id.you can use a MFmailcompossor to compose mail from your app.
Hope this help

Related

Upload image to form in webview, without displaying image picker

I am trying to fill up a web form and submit data without letting the user see the web form itself. I have tried using AFNetworking to do HTTP POST in the background, but I bumped into a problem which I couldn't solve and decided to try something else.
This time, I have a UIWebView which is hidden in the background. I then edit the text in the respective fields using Javascript in the webViewDidFinishLoad:webView as follows:
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
[params setObject:nameField.text forKey:#"name"];
[params setObject:emailField.text forKey:#"email"];
[params setObject:titleField.text forKey:#"title"];
[params setObject:dateString forKey:#"link"];
[params setObject:descriptionTV.text forKey:#"content"];
[params setObject:tag forKey:#"tags"];
[params enumerateKeysAndObjectsUsingBlock:^(id key, id object, BOOL *stop) {
NSLog(#"%# = %#", key, object);
NSString *javascriptString = [NSString stringWithFormat:#"document.getElementById('%#').value = '%#'",key,object];
[webView stringByEvaluatingJavaScriptFromString:javascriptString];
}];
Is there any way I could do the same, but for uploading images/files?
You should use an NSHTTPRequest to POST the image to the form directly. There is no need to use a UIWebView, hidden or otherwise. See this answer for an example of how to implement this. Here is another example of this.

Share image on facebook using FBConnect

After searching 2 days on it m finally posting my code.
Application Description: I am choosing an image through imagePicker and after editing it I want to share it on Facebook.
Problem: I can post the text on my wall but not the image, as i dont have any URL i cant find another way to post image on my wall.
here is the code ( which i stole from another application) of my PostToWall
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = #"Enter your message:";
dialog.actionLinks = #"[{\"Get DowntownLA!\",\"href\":\"http://www.facebook.com/DowntownLA.com/\"}]";
dialog.attachment = [NSString stringWithFormat:
#"{ \"name\":\"%#\","
"\"href\":\"%#\","
"\"caption\":\"%#\",\"description\":\"%#\","
"\"media\":[{\"type\":\"image\","
"\"src\":\"%#\","
"\"href\":\"%#\"}],"
"\"properties\":{\"%#\":{\"text\":\"%#\",\"href\":\"%#\"}}}", #"name: priya",#"href nothing",#"cation nothing",#"description nothin", #"imageSource nothing ", #"imageHref nothing", #"linkTitle nothing", #"linkText nothing", #"linkHref nothing"];
[dialog show];
Please tel me wher m going wrong !!!!!
The error m getting on simulator is : Application Response Error - The post action links must be valid URls. You can see this because you are one of the developers of the app.
i have upload image in this way
- (void) postOnFBWall
{
NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:2];
//create a UIImage (you could use the picture album or camera too)
UIImage *picture = imgUploadPhoto.image;
//create a FbGraphFile object insance and set the picture we wish to publish on it
FbGraphFile *graph_file = [[FbGraphFile alloc] initWithImage:picture];
//finally, set the FbGraphFileobject onto our variables dictionary....
[variables setObject:graph_file forKey:#"file"];
NSString * messageValue = [NSString stringWithFormat:#"Menu Name: %#, Restaurant: %#, Category: %#, Comment: %#",txtNameofMenu.text,txtRestaurant.text,categoryLbl.text,txtViewComment.text];
[variables setObject:[NSString stringWithFormat:#"%#",messageValue] forKey:#"message"];
//the fbGraph object is smart enough to recognize the binary image data inside the FbGraphFile
//object and treat that is such.....
FbGraphResponse *fb_graph_response = [[FBRequestWrapper defaultManager] doGraphPost:#"me/photos" withPostVars:variables];
NSLog(#"postPictureButtonPressed: %#", fb_graph_response.htmlResponse);
}

FBConnect iphone : I coud'nt get Photos albums for some account ?

Maybe someone can't help me.
I use the last FBConnect (http://github.com/facebook/facebook-ios-sdk/) for Facebook connexion.
And I retreive the list of photos albums for the user.
NSMutableDictionary* params = [NSMutableDictionary NictionaryWithObjectsAndKeys:_facebook.accessToken,#"access_token",nil];
[_facebook requestWithGraphPath:#"me/albums" andParams:params andDelegate:self];
I'm testing with 4 differents account with all the same rules for privacy (Account/Privacy settings). And for some of them the albums list is empty ? And if i test via a webbrowser on a desktop computer (https://graph.facebook.com/me/albums) for account who doesn't work on iphone, the list is not empty ?
On iphone, i use graph api or FQL with same results ("SELECT aid FROM album WHERE owner = me()")
Maybe i miss some think about configuration off the facebookapp ?
Thanks for answer.
I resolve the solution with good settings for facebook authentifications
http://developers.facebook.com/docs/authentication/permissions
THIS WILL PUT ALL THE IMAGES OF THE ALBUM IN SOURCE ARRAY!
NSURL *url1 = [NSURL URLWithString:[NSString stringWithFormat:#"https://graph.facebook.com/%#/photos&access_token=AAACeFkezepQBANpoFq9I3Hts0JdE6Xis3UpZBqNxpgw62zWSlhSYyYcluGaaxH3IlKIh9w8OYrXYF9MsAxhk6ta1ANZClCaznpdSaERgZDZD",A_ID]];
URLWithString:#"https://graph.facebook.com/114750591966408/photos&access_token=//AAACeFkezepQBANpoFq9I3Hts0JdE6Xis3UyYcluGaaxH3IlKIh9w8OYrXYF9MsAxhk6ta1ANZClCaznpdSaERgZDZD"];
NSData *data1 = [NSData dataWithContentsOfURL:url1];
NSString *str1=[[NSString alloc] initWithData:data1 encoding:NSASCIIStringEncoding];
// NSString *str1=[[NSString alloc]ini]
NSDictionary *userData1 = [str1 JSONValue];
NSArray *arrOfimages=[userData1 objectForKey:#"data"];
NSMutableArray *sourceUrls = [[NSMutableArray alloc] initWithCapacity:0];
for(NSDictionary *subDictionary in arrOfimages)
{
[sourceUrls addObject:[subDictionary objectForKey:#"picture"]];
}
publish_actions and user_photos permissions is required.
And then please try the following code :
[FBRequestConnection startWithGraphPath:#"me/albums"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Success! Include your code to handle the results here
NSLog(#"user events: %#", result);
NSArray *feed =[result objectForKey:#"data"];
for (NSDictionary *dict in feed) {
NSLog(#"first %#",dict);
}
} else {
// An error occurred, we need to handle the error
// Check out our error handling guide: https://developers.facebook.com/docs/ios/errors/
NSLog(#"error %#", error.description);
}
}];

Facebook graph api with native iPhone application

I want to use the Facebook Graph API in a NATIVE iPhone Application. Has anybody been able to find a way to post images/message on a user's feed?
I have tried all possible ways to post a ‘picture’ (not a URL but a UIImage) on the feed and have been working on this for 2 weeks now.
If you go to facebook.com you can upload a picture from your computer on to the wall. I am using ASIHTTPRequest to work on facebook graph API.
This is the nearest I have gone to posting a picture on the feed. So if I have a ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
The url is https://graph.facebook.com/me/feed
Now to post a picture I do the following:
[request setPostValue:#"My Message" forKey:#"message"];
[request setPostValue:#"somepic.png" forKey:#"picture"];
[request setPostValue:#"Some Name" forKey:#"name"];
[request setPostValue:#"Some description" forKey:#"description];
[request startAsynchronous];
If you try this then everything works fine other than the picture being posted. A blank placeholder for the picture is though show on the feed.
I created a method to help me do this. Hope this is of some help.
Please read the tutorial on how to set up the Facebook SDK.
-(void) updateStatusWithText:(NSString *) fbTitle //Status title
andStoryURL:(NSString *) fbURL //URL for the story
andStory:(NSString *) fbStory //The story
andImage:(NSString *) imageURL //Image to be displayed.
andPrompt:(NSString *) promptString{
NSLog(#"updateStatusWithText");
NSString *attachmentText =[NSString stringWithFormat:#"{\"name\":\"%#\","
"\"href\":\"%#\","
"\"description\":\"%#\","
"\"media\":[{\"type\":\"image\","
"\"src\":\"%#\","
"\"href\":\"%#\"}],"
"\"properties\":{\"Uploaded from an iPhone\":{\"text\":\"AFL Fan\",\"href\":\"Your itunes apstore URL\"}}}", fbTitle, fbURL, fbStory,imageURL,fbURL];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
promptString, #"user_message_prompt",
// actionLinksStr, #"properties",
attachmentText, #"attachment",
nil];
NSLog (#"attachmentText : %#", attachmentText);
[facebook dialog:#"stream.publish"
andParams:params
andDelegate:self];
}

FBConnect (IPHONE) , custom publish dialog

is possible custominzing the FBdialog??, i have already modify the attachment on the dialog when the user wants to publish a post; but i need to make hidden the textfield that the dialog presents...there is a way to access to this property or it's just a webView that load a page from facebook's server?
sorry for my bad english!
thanks in advance
Yes, this is possible. just design your own UI and pass the message to a method containing this code:
NSString *message = #"test message here";
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:message forKey:#"message"];
[params setObject:toID forKey:#"target_id"];
[[FBRequest requestWithDelegate:self] call:#"facebook.Stream.publish" params:params];