私のWebサービスを使用しているiOS開発者から配列を取得するために、次のコードを使用しています。
$handle = fopen('php://input','r');
$jsonInput = fgets($handle);
$decoded = json_decode($jsonInput,true);
Android用に同じものを作成したいので、使用します
$_POST
配列入力を取得します。
配列入力を取得する一般的な方法は何ですか。そのため、2 つの異なるコードを記述する必要はありません。
次のコードを使用する ios 開発者
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:WEB_URL]];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"username",@"username",@"password",@"password",textboxMobile.text,@"mobile",textboxEmail.text,@"email",deviceidnew,@"device_id",cityid,@"city_id",[NSString stringWithFormat: @""],@"othercity",areaidstore,@"area_id",[NSString stringWithFormat: @""],@"otherarea",self.textboxName.text,@"name",khidmatarraylist,@"khidmat_id",userid,@"user_id",@"editprofileiphone",@"tag",nil];
SBJSON *parser =[[SBJSON alloc] init];
NSString *jsonString = [parser stringWithObject:dict];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[jsonString dataUsingEncoding:NSUTF8StringEncoding]];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
これらのリンクを確認しました:
「php://input」とは何ですか? 主にWebサービスで見られる
json で辞書を送信していますが、2 つの配列と複数の値がありますが、応答アクセスが拒否されています
しかし、それほど多くの提案はありませんか?
前もって感謝します