내 응용 프로그램을 통해 yFrog를 사용하여 트위터에 이미지 및 비디오를 게시하려고하지만 요청을 할 때 아무 것도 일어나지 않는 것 같습니다 ... 누군가 내가 뭘 잘못하고 있는지 또는 나를 가리켜 주실 수 있습니까? 바른 길? 당신은 내가 당신이 대리인에게 자기 설정을 참조하지만 콜백이 표시되지 않는 대리자 (위 적어도 코드에서) 메소드를 다시 호출 구현하지 않을yFrog에 게시 objc
-(IBAction)yFrogToTwitter
{
// create the URL
//used to render bigger images videos
//NSURL *postURL = [NSURL URLWithString:@"http://render.imageshack.us/renderapi/start"];
//below is used to directly upload to twitter
NSURL *postURL = [NSURL URLWithString:@"http://yfrog.com/api/uploadAndPost"];
// create the connection
NSMutableURLRequest *postRequest = [NSMutableURLRequest requestWithURL:postURL
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:30.0];
// change type to POST (default is GET)
[postRequest setHTTPMethod:@"POST"];
// create data
NSMutableData *postBody = [NSMutableData data];
//NSString *media = PickedImage.image;
NSString *username = twitterEngine.username;
NSString *password = twitterEngine.password;
NSString *message = TweetBody.text;
NSString *source = @"ThemeCatcher";
NSString *api_key= kYFrogKey;
// just some random text that will never occur in the body
NSString *stringBoundary = @"0xKhTmLbOuNdArY---This_Is_ThE_BoUnDaRyy---pqo";
// header value
NSString *headerBoundary = [NSString stringWithFormat:@"multipart/form-data;
boundary=%@",stringBoundary];
// set header
[postRequest addValue:headerBoundary forHTTPHeaderField:@"Content-Type"];
// username part
[postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", stringBoundary]
dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data;
name=\"username\"\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[username dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
// password part
[postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", stringBoundary]
dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data;
name=\"password\"\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[password dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
// api_key
[postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", stringBoundary]
dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data;
name=\"key\"\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[api_key dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
// message part
[postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", stringBoundary]
dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data;
name=\"message\"\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[message dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
// source part
[postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", stringBoundary]
dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data;
name=\"source\"\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[source dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
// media part
[postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", stringBoundary]
dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[@"Content-Disposition: form-data; name=\"media\";
filename=\"fish.jpg\"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[@"Content-Type: image/jpeg\r\n"
dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[@"Content-Transfer-Encoding: binary\r\n\r\n"
dataUsingEncoding:NSUTF8StringEncoding]];
NSData *imageData = UIImagePNGRepresentation(PickedImage.image);
// add Image to body
[postBody appendData:imageData];
[postBody appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
// final boundary
[postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", stringBoundary]
dataUsingEncoding:NSUTF8StringEncoding]];
// add body to post
[postRequest setHTTPBody:postBody];
// pointers to some necessary objects
//NSURLResponse* response;
//NSError* error;
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:postRequest
delegate:self];
if(theConnection)
{
webData = [[NSMutableData data] retain];
}
else
{
NSLog(@"theConnection is NULL");
}
}
답변이 잘못되었거나 부분적으로 정확하지 않은 경우 질문에 대답하는 사용자에게 의견을 보내어 답변을 개선 할 수 있도록하십시오. 감사. –
감사합니다. 나는 Stackoverflow를 사랑하고 내가 이것을 원한다면 누군가에게 불쾌감을주지 않기를 바랍니다. 나는 옳다고 생각했던 것을하고 있었지만 완전히 얻은 것이 두 가지 모두 였고 미래의 모든 질문에 대해 이것을 명심할 것입니다. – FreeAppl3
물론 도움이되지 않았습니다. Thx – bryanmac