NSURLSessionDataTask gives me incorrect token in a Login - objective-c

I'm updating an iOS app in objective c, and i have the warning sendSynchronousRequest(_:returningResponse:) was deprecated in iOS 9.0: Use [NSURLSession dataTaskWithRequest:completionHandler:]
So I changed my code from:
-(NSString*)getServerResponseByMethod:(NSString*)method clientId:(NSString*)clientId deviceid:(NSString*)deviceid token:(NSString*)token parameters:(NSDictionary*)parameters{
NSString *reponseStr;
NSMutableData *postbody = [NSMutableData data];
Setting *session =[Setting getSessionDataInstance];
NSString *todayDate=[Utils Datefromstring:[NSDate date] byFormatter:#"HH:mm:ss"];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"%#/services/?&time=%#", appDelegate.mainUrlString,todayDate]];
NSMutableURLRequest *request=(NSMutableURLRequest*)[NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:600.0];
if([method isEqualToString:#"userLogin"])
{
[postbody appendData:[[NSString stringWithFormat:#"&param=login"] dataUsingEncoding:NSUTF8StringEncoding]];
[postbody appendData:[[NSString stringWithFormat:#"&username=%#",[parameters objectForKey:#"userName"]] dataUsingEncoding:NSUTF8StringEncoding]];
[postbody appendData:[[NSString stringWithFormat:#"&password=%#",[parameters objectForKey:#"password"]] dataUsingEncoding:NSUTF8StringEncoding]];
[postbody appendData:[[NSString stringWithFormat:#"&apnstoken=123456789"] dataUsingEncoding:NSUTF8StringEncoding]];
}
if([method isEqualToString:#"userLogout"])
{
[postbody appendData:[[NSString stringWithFormat:#"&param=logOut"] dataUsingEncoding:NSUTF8StringEncoding]];
[postbody appendData:[[NSString stringWithFormat:#"&user_id=%#",session.userId] dataUsingEncoding:NSUTF8StringEncoding]];
[request addValue:[NSString stringWithFormat:#"%#",session.sessionToken ] forHTTPHeaderField:#"token"];
}
NSString * dataLength = [NSString stringWithFormat:#"%lu",(unsigned long)[postbody length]];
[request addValue:dataLength forHTTPHeaderField:#"Content-Length"];
[ request setHTTPMethod: #"POST" ];
[ request setValue:#"application/x-www-form-urlencoded" forHTTPHeaderField:#"content-type"];
[ request setHTTPBody: postbody ];
NSLog(#"request===%#",[request allHTTPHeaderFields]);
NSLog(#"URL=====%#",[request URL]);
NSLog(#"request===%#",request);
NSError *theError = nil;
NSURLResponse *urlResponse = nil;
if ([self checkInternet])
{
//THE PART OF THE WARNING ------
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&theError];
if(theError==nil){
reponseStr= [[NSString alloc] initWithData:returnData encoding:NSASCIIStringEncoding];
NSLog(#"ServerResponse===%#",reponseStr);
}
else{
NSLog(#"sendSynchronousRequest error = %#",theError.localizedDescription);
}
}
else{
reponseStr=#"Network not Available.";
}
return reponseStr;
}
- (BOOL) connectedToNetwork
{
Reachability *r = [Reachability reachabilityForInternetConnection];
NetworkStatus internetStatus = [r currentReachabilityStatus];
BOOL internet;
if ((internetStatus != ReachableViaWiFi) && (internetStatus != ReachableViaWWAN))
{
internet = NO;
} else {
internet = YES;
}
return internet;
}
-(BOOL) checkInternet
{
//Make sure we have internet connectivity
if([self connectedToNetwork] != YES)
{
return NO;
}
else {
return YES;
}
}
NEW CODE --just adding the parts that modified
-(NSString*)getServerResponseByMethod:(NSString*)method clientId:(NSString*)clientId deviceid:(NSString*)deviceid token:(NSString*)token parameters:(NSDictionary*)parameters
{
__block NSString *reponseStr;
.......
NSString * dataLength = [NSString stringWithFormat:#"%lu",(unsigned long)[postbody length]];
[request addValue:dataLength forHTTPHeaderField:#"Content-Length"];
[request setHTTPMethod: #"POST" ];
[request setValue:#"application/x-www-form-urlencoded" forHTTPHeaderField:#"content-type"];
[request setHTTPBody: postbody ];
NSLog(#"request===%#",[request allHTTPHeaderFields]);
NSLog(#"URL=====%#",[request URL]);
NSLog(#"request===%#",request);
//NSError *theError = nil;
//NSURLResponse *urlResponse = nil;
if ([self checkInternet])
{
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error){
if(error==nil)
{
reponseStr = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSLog(#"ServerResponse===%#",reponseStr);
}
else
{
NSLog(#"sendSynchronousRequest error = %#",error.localizedDescription);
}
}];
[task resume];
}
else
{
reponseStr=#"Network not Available.";
}
return reponseStr;
}
With this new code, every time I log in displays the message that my username or password is incorrect but with the deprecated method everything works fine.
Any help will be awesome! I've been struggling with this like 3 hours :(
Thanks!

It seems you mixed up between POST or GET in your post body.
Any URL with format
http://abcde.com/what.php?a=1&b=2
is a GET method.
And what you specify is POST method. So make clear about that first.
Secondly, if you are using POST, then the data to post should be formatted
properly (example: https://stackoverflow.com/a/19101084/501439). All the "&"
in your postbody is causing the problem I am sure.

Related

Status code 400 when converting Postman Request into Objective-C

I'm trying to upload an image to an API and then use the result. When using Postman, everything runs successfully. When I used the export feature to convert the code to Objective-C, I tried running it, but I'm getting a status code 400 (my parameters are invalid).
Here is the Postman request:
Here is my own code:
// Get image name
NSURL *refURL = [info valueForKey:UIImagePickerControllerReferenceURL];
PHFetchResult *result = [PHAsset fetchAssetsWithALAssetURLs:#[refURL] options:nil];
NSString *filename = [[result firstObject] filename];
// Get image file path and append file name onto it
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:filename];
[imageData writeToFile:path atomically:YES];
NSDictionary *headers = #{ #"content-type": #"multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
#"Content-Type": #"multipart/form-data",
#"Accept": #"application/json",
#"Authorization": #"Token 60f6be2a21bdf731d86a8817b440a1afba692fed",
#"Cache-Control": #"no-cache",
#"Postman-Token": #"7d262730-0c7d-66dc-bbbb-43f40dbfe8ce" };
NSArray *parameters = #[ #{ #"name": #"task", #"value": #"dc9ef71a-b8a0-4a12-90fd-83d717cf887f" },
#{ #"name": #"image_file", #"fileName": path } ];
NSString *boundary = #"----WebKitFormBoundary7MA4YWxkTrZu0gW";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:#"--%#\r\n", boundary];
if (param[#"fileName"]) {
[body appendFormat:#"Content-Disposition:form-data; name=\"%#\"; filename=\"%#\"\r\n", param[#"name"], param[#"fileName"]];
[body appendFormat:#"Content-Type: %#\r\n\r\n", param[#"contentType"]];
[body appendFormat:#"%#", [NSString stringWithContentsOfFile:param[#"fileName"] encoding:NSASCIIStringEncoding error:&error]];
if (error) {
NSLog(#"%#", error);
}
} else {
[body appendFormat:#"Content-Disposition:form-data; name=\"%#\"\r\n\r\n", param[#"name"]];
[body appendFormat:#"%#", param[#"value"]];
}
}
[body appendFormat:#"\r\n--%#--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSASCIIStringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:#"https://api.vize.ai/v1/classify/"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:#"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(#"%#", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(#"%#", httpResponse);
}
}];
[dataTask resume];
(It's not shown here, but I'm trying to use an image that the user will select from an image picker.) Why am I getting a status code 400 and how can I get the correct result?

Multipartform Data -Image Uploading

I want to uload the image and dictionary to server , i have done something , image is not uploading dictionary is workinfine ,here is my code,
NSData *jsonData = [NSJSONSerialization dataWithJSONObject: dict
options:0
error:nil];
NSString *jsonString =[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSDictionary *headers = #{ #"content-type": #"multipart/form-data; boundary=---011000010111000001101001",
#"cache-control": #"no-cache",
#"postman-token": #"f93b7bb9-040f-fa7c-8a65-5a4f8e057cfe" };
NSArray *parameters = #[ #{ #"name": #"userDetails", #"value":jsonString }
,#{ #"name": #"userImage", #"fileName":#{#"0":#{}}}
];
NSString *boundary = #"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:#"--%#\r\n", boundary];
if (param[#"fileName"]) {
[body appendFormat:#"Content-Disposition:form-data; name=\"%#\"; fileName=\"%#\"\r\n", param[#"name"], param[#"fileName"]];
[body appendFormat:#"Content-Type: %#\r\n\r\n", param[#"contentType"]];
[body appendFormat:#"%#", [NSString stringWithContentsOfFile:param[#"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(#"%#", error);
}
} else {
[body appendFormat:#"Content-Disposition:form-data; name=\"%#\"\r\n\r\n", param[#"name"]];
[body appendFormat:#"%#", param[#"value"]];
}
}
[body appendFormat:#"\r\n--%#--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:#"---.php"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:#"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(#"%#", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(#"%#", httpResponse);
NSString *stringFromData = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(#"%#",stringFromData);}}];
[dataTask resume];}
i got the msg from server is success,uploaded successfully,but image is not uploaded , i have checked in server ,Please help me to upload the image

How to print xml file returned by the server

it is the first time i'm dealing with server communication trough HTTP requests and in order to be sure of what i'm doing, and have "matter between my hands" i want to print the xml file that the server should return to me.
If someone could help me please :
Here is my code :
(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if ([stories count] == 0) {
NSString * l_api_key = #"********************************************";
NSString * l_secret_key = #"******************************************";
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:[#myURLHERE stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]
cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
timeoutInterval:60.0];
[theRequest setHTTPMethod:#"POST"];
[theRequest setValue:#"application/xml" forHTTPHeaderField:#"Accept"];
[theRequest setValue:#"application/x-www-form-unrlencoded" forHTTPHeaderField: #"Content-Type"];
[theRequest addValue:l_api_key forHTTPHeaderField: #"EMApikey"];
[theRequest addValue:[self hmacsha1:l_api_key secret:l_secret_key] forHTTPHeaderField: #"EMRequestHash"];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
NSLog(#"%#", theConnection);
if( theConnection )
{
NSData *webData = [[NSMutableData data] retain];
NSLog(#"%#", webData);
//[self parseXMLFileAtURL:path];
}
else
{
NSLog(#"theConnection is NULL");
}
[theConnection release];
}
cellSize = CGSizeMake([newsTable bounds].size.width, 60);
}
[NSURLConnection sendAsynchronousRequest:theRequest
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
NSLog(#"%#", [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]);
}];
it's more convenient than:
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
You need to send the POST request and get back the response, see the example below :
//create the body
NSMutableData *postBody = [NSMutableData data];
[postBody appendData:[[NSString stringWithFormat:#"<xml>"] dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[[NSString stringWithFormat:#"<yourcode/>"] dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[[NSString stringWithFormat:#"</xml>"] dataUsingEncoding:NSUTF8StringEncoding]];
//post
[theRequest setHTTPBody:postBody];
//get response
NSHTTPURLResponse* urlResponse = nil;
NSError *error = [[NSError alloc] init];
NSData *responseData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&urlResponse error:&error];
NSString *result = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(#"Response Code: %d", [urlResponse statusCode]);
if ([urlResponse statusCode] >= 200 && [urlResponse statusCode] < 300) {
NSLog(#"Response: %#", result);
//here you get the response
}

Post data on web server with web service

Hello I am tying to save data on web server with a web service implemented in PHP.
I am trying below code to do it. I am getting response from server but the data is not getting saved to server. I have wasted 5-6 hours of the day in googling and trying code given on net. But nothing seems to work :(
NSDictionary *someInfo = [NSDictionary dictionaryWithObjectsAndKeys:
txtTreasureName.text, #"name",
txtDescription.text, #"description",
txtMaterials.text, #"materials",
#"77.3833", #"longitude",
#"29.0167", #"latitude",
categoryIdStr, #"categoryId",
nil];
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:treasureInfo
options:NSJSONWritingPrettyPrinted
error:&error];
if (! jsonData) {
DLog(#"Got an error: %#", error);
} else {
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSString *urlString = #"http://www.myurl.php";
NSURL *url = [NSURL URLWithString:urlString];
[request setURL:url];
[request setHTTPMethod:#"POST"];
[request setValue:#"application/json"
forHTTPHeaderField:#"Content-Type"];
[request setValue:#"application/json"
forHTTPHeaderField:#"Accept"];
[request setValue:[NSString stringWithFormat:#"%d",
[jsonData length]]
forHTTPHeaderField:#"Content-length"];
[request setHTTPBody:jsonData];
DLog(#"%#", request);
[[NSURLConnection alloc]
initWithRequest:request
delegate:self];
// Print json
DLog(#"JSON summary: %#", [[NSString alloc] initWithData:jsonData
encoding:NSUTF8StringEncoding]);
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
[NSURLConnection sendAsynchronousRequest:request
queue:queue
completionHandler:^(NSURLResponse *response,
NSData *data, NSError *error) {
if ([data length] &&
error == nil) {
DLog(#"%#", [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding]);
if ([self shouldDismiss]) {
[self dismissViewControllerAnimated:YES
completion:nil];
}
}
}];
}
Set Request URL in the function,
You have alread y created data Dictionary
NSDictionary *someInfo = [NSDictionary dictionaryWithObjectsAndKeys:
txtTreasureName.text, #"name",
txtDescription.text, #"description",
txtMaterials.text, #"materials",
#"77.3833", #"longitude",
#"29.0167", #"latitude",
categoryIdStr, #"categoryId",
nil];
Add this function to your implementation file and invoke it, rest will be dont by this function
[self postWith:someInfo];
Add this
- (void)postWith:(NSDictionary *)post_vars
{
#warning Add your Webservice URL here
NSString *urlString = [NSString stringWithFormat:#"YourHostString"];
NSURL *url = [NSURL URLWithString:urlString];
NSString *boundary = #"----1010101010";
// define content type and add Body Boundry
NSString *contentType = [NSString stringWithFormat:#"multipart/form-data; boundary=%#",boundary];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:#"POST"];
[request addValue:contentType forHTTPHeaderField: #"Content-Type"];
NSMutableData *body = [NSMutableData data];
[body appendData:[[NSString stringWithFormat:#"--%#\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
NSEnumerator *enumerator = [post_vars keyEnumerator];
NSString *key;
NSString *value;
NSString *content_disposition;
while ((key = (NSString *)[enumerator nextObject])) {
value = (NSString *)[post_vars objectForKey:key];
content_disposition = [NSString stringWithFormat:#"Content-Disposition: form-data; name=\"%#\"\r\n\r\n", key];
[body appendData:[content_disposition dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[value dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:#"\r\n--%#\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
}
//Close the request body with Boundry
[body appendData:[[NSString stringWithFormat:#"\r\n--%#--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];
[request addValue:[NSString stringWithFormat:#"%d", body.length] forHTTPHeaderField: #"Content-Length"];
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
NSLog(#"%#", returnString);
}

iOS YouTube Video Upload Error

I am trying to upload a video using Objective-C and YouTube API but it is not working and return error at last step. The error reads "User authentication required".
I am following this API document specifically the one which is without metadata. I got the authentication token with ClientLogin API
I checked authentication token with NSLog and it's there. I see the upload API also returns Upload URL but when I send HTTP PUT request to retrieved Upload URL, it returns an error mentioned above.
Here's Upload Code
- (bool) upload:(NSString *)file {
NSData *fileData = [NSData dataWithContentsOfFile:file];
NSURL *url = [NSURL URLWithString:self.UploadURL];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:#"PUT"];
[request setValue:#"Content-Type" forHTTPHeaderField:#"application/octet-stream"];
[request setValue:#"Content-Length" forHTTPHeaderField:[NSString stringWithFormat:#"%ud", [fileData length]]];
[request setHTTPBody:fileData];
NSError *requestError;
NSURLResponse *urlResponse = nil;
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&requestError];
NSLog(#"%#", [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]);
if (response == nil) {
return NO;
} else {
return YES;
}
}
I also tried the Direct Upload method but this always gives me Invalid Request error. Below is the code.
- (bool) directUpload:(NSString *)file {
NSString *title = [file lastPathComponent];
NSString *desc = #"This is test video.";
NSString *category = #"People";
NSString *keywords = #"video";
NSString *boundary = #"--qwerty";
NSString *xml = [NSString stringWithFormat:
#"<?xml version=\"1.0\"?>"
#"<entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:media=\"http://search.yahoo.com/mrss/\" xmlns:yt=\"http://gdata.youtube.com/schemas/2007\">"
#"<media:group>"
#"<media:title type=\"plain\">%#</media:title>"
#"<media:description type=\"plain\">%#</media:description>"
#"<media:category scheme=\"http://gdata.youtube.com/schemas/2007/categories.cat\">%#</media:category>"
#"<media:keywords>%#</media:keywords>"
#"</media:group>"
#"</entry>", title, desc, category, keywords];
NSData *fileData = [NSData dataWithContentsOfFile:file];
NSMutableData *postBody = [NSMutableData data];
[postBody appendData:[[NSString stringWithFormat:#"%#\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[[NSString stringWithFormat:#"Content-Type: application/atom+xml; charset=UTF-8\n\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[xml dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[[NSString stringWithFormat:#"%#\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[[NSString stringWithFormat:#"Content-Type: video/mp4\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[[NSString stringWithFormat:#"Content-Transfer-Encoding: binary\n\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:fileData];
[postBody appendData:[[NSString stringWithFormat:#"%#", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
NSURL *url = [NSURL URLWithString:#"http://uploads.gdata.youtube.com/feeds/api/users/default/uploads"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:#"POST"];
[request setValue:[NSString stringWithFormat:#"GoogleLogin auth=\"%#\"", self.AuthToken] forHTTPHeaderField:#"Authorization"];
[request setValue:#"2" forHTTPHeaderField:#"GData-Version"];
[request setValue:[NSString stringWithFormat:#"key=%#", self.DeveloperKey] forHTTPHeaderField:#"X-GData-Key"];
[request setValue:[file lastPathComponent] forHTTPHeaderField:#"Slug"];
[request setValue:[NSString stringWithFormat:#"multipart/related; boundary=\"%#\"", boundary] forHTTPHeaderField:#"Content-Type"];
[request setValue:[NSString stringWithFormat:#"%ud", [postBody length]] forHTTPHeaderField:#"Content-Length"];
[request setValue:#"close" forHTTPHeaderField:#"Connection"];
[request setHTTPBody:postBody];
NSError *requestError;
NSURLResponse *urlResponse = nil;
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&requestError];
NSLog(#"%#", [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]);
if (response == nil) {
return NO;
} else {
return YES;
}
}
i think you should check this :-
https://developers.google.com/youtube/2.0/developers_guide_protocol_video_feeds
and you also check this :-
http://urinieto.com/2010/10/upload-videos-to-youtube-with-iphone-custom-app/