久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在 HTTP post 中向 PHP 服務器發送多個參數

How to send multiple parameterts to PHP server in HTTP post(如何在 HTTP post 中向 PHP 服務器發送多個參數)
本文介紹了如何在 HTTP post 中向 PHP 服務器發送多個參數的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

I'm sending base64 string to php server and its working well. Now I want to send another parameter as a string. Can anyone tell me what code need to add in below code.

Below code is working good for single parameter. How can we modify it for multiple parameters?

 NSData *data = [UIImageJPEGRepresentation(imgeview.image,90) base64Encoding];

// Create your request string with parameter name as defined in PHP file
NSString *myRequestString = [NSString stringWithFormat:@"question_image=%@",data];
myRequestString = [myRequestString stringByReplacingOccurrencesOfString:
                                             @"+" withString:@"%2B"];

// Create Data from request
NSData *myRequestData = [NSData dataWithBytes:[myRequestString UTF8String] 
                                       length:[myRequestString length]];
request = [[NSMutableURLRequest alloc] initWithURL:
    [NSURL URLWithString:@"http://192.168.0.101/Mobile_tutor/webservice/question_details.php"]];
// set Request Type
[request setHTTPMethod:@"POST"];
// Set content-type
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
// Set Request Body
[request setHTTPBody:myRequestData];
// Now send a request and get Response
NSData *returnData = [NSURLConnection sendSynchronousRequest:request 
                                           returningResponse:nil 
                                                       error: nil];
// Log Response
NSString *response = [[NSString alloc] initWithBytes:[returnData bytes] 
                                              length:[returnData length]
                                            encoding:NSUTF8StringEncoding];
NSLog(@"-------------%@",response); // here you get reasponse string

解決方案

For the network operation these is better supporting API like AFNetworking available witch work async and way better to handle

Tutorials for AFNetworking

Get from here

NSArray *keys = @[@"UserID", ];
NSArray *objects = @[@(userId)];

NSDictionary *parameter = [NSDictionary dictionaryWithObjects:objects forKeys:keys];

AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:
                            [NSURL URLWithString:BaseURLString]];
[httpClient setParameterEncoding:AFJSONParameterEncoding];
[httpClient registerHTTPOperationClass:[AFJSONRequestOperation class]];

NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST"
                                                        path:@"services/UserService.svc/GetUserInfo"
                                                  parameters:parameter];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {

    NSError* error = nil;
    id jsonObject = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:&error];
    if ([jsonObject isKindOfClass:[NSDictionary class]]) {
        // do what ever
    }
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

}];

這篇關于如何在 HTTP post 中向 PHP 服務器發送多個參數的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Using Instruments to test an iOS app without having source code to the application(在沒有應用程序源代碼的情況下使用 Instruments 測試 iOS 應用程序)
KIF: How to auto-run/stress test an iOS app to find the cause of a rare UI bug?(KIF:如何自動運行/壓力測試 iOS 應用程序以找出罕見 UI 錯誤的原因?)
Can#39;t change target membership visibility in Xcode 4.5(無法更改 Xcode 4.5 中的目標成員身份可見性)
UITableView: Handle cell selection in a mixed cell table view static and dynamic cells(UITableView:在混合單元格表視圖靜態和動態單元格中處理單元格選擇)
How to remove Address Bar in Safari in iOS?(如何在 iOS 中刪除 Safari 中的地址欄?)
iOS 5 SDK is gone after upgrade to Xcode 4.5(升級到 Xcode 4.5 后,iOS 5 SDK 消失了)
主站蜘蛛池模板: 国产精品美女久久久久久免费 | 亚洲综合伊人 | 国产羞羞视频在线观看 | 久久综合久久综合久久综合 | 日本黄色一级片视频 | 99在线精品视频 | 国产精品海角社区在线观看 | 国内精品视频免费观看 | 欧美精品v国产精品v日韩精品 | 亚洲精品久久久一区二区三区 | 国产欧美日韩综合精品一 | 国产精品一区在线播放 | 91精品久久久久 | 欧美日韩一区在线播放 | 蜜桃在线视频 | 免费av手机在线观看 | 国产精品美女久久久免费 | 欧美国产亚洲一区二区 | 国产欧美一区二区三区日本久久久 | 久久久久久九九九九九九 | 国产精品久久久久久 | 午夜二区 | 一本一道久久a久久精品综合 | av首页在线| 久艹网站 | 麻豆毛片| 国产内谢 | 精品一区久久 | 丁香五月网久久综合 | 亚洲综合99| 91在线第一页 | 欧美国产视频 | 免费一区二区 | 国产成人精品久久久 | 日韩在线欧美 | 成人精品一区二区 | 国产欧美精品 | 日韩视频国产 | 欧美性一区二区三区 | 欧美色影院 | 精品日韩在线 |