久久久久久久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 消失了)
主站蜘蛛池模板: 亚洲精品国产一区 | 国外成人在线视频 | 成人精品一区二区 | 日韩成人一区 | 日韩一二区 | 久久久91精品国产一区二区三区 | 亚洲欧美国产毛片在线 | 亚洲一区二区三区视频在线 | 天天操天天摸天天干 | 国产欧美日韩精品一区 | 国产一区二区在线免费观看 | 成人在线观看黄 | 久久av一区二区三区 | 黄色网址在线播放 | 中文字幕日韩欧美一区二区三区 | 日韩一区二区三区在线观看 | 中文字幕高清 | 狠狠干美女 | 九九av | 欧美理论片在线观看 | 日本久久精品 | 亚洲精品大全 | 手机在线一区二区三区 | 精品免费视频 | 亚洲精品综合 | 国产精品福利在线 | 日韩精品一区二区三区视频播放 | 自拍偷拍第1页 | 亚洲欧美一区二区三区情侣bbw | 欧美精品一| 色综合久久久久 | 成人久久久 | 亚洲网站在线观看 | 欧美成人激情视频 | 日韩一级在线 | 欧州一区 | 免费av一区二区三区 | 精品国产乱码一区二区三 | 久久久久久久久久久久久九 | 美女久久 | 久久999|