如何使用 post 将数据发送到 url?安卓 Kotlin

问题描述 投票:0回答:0

我想使用 Kotlin 将数据发送到我的 url。我该怎么做?我将 Retrofit 与 field post 一起使用,但没有用。 Http 请求可能有效,但我找不到合适的方法。发送数据是否应该是 json?

主要活动

lifecycleScope.launch {
     doPostRequest()
}
private suspend fun doPostRequest() {
     withContext(Dispatchers.IO) {
         // 
     }
}

我的 Php 文件

<?php

    $tuccar_id = $_POST['merchant_id'];
    $tuccar_key = $_POST['merchant_key'];
    $tuccar_salt = $_POST['merchant_salt'];
    $tuccar_oid = $_POST['merchant_oid'];
    $sepet = $_POST['user_basket'];
    $mail = $_POST['email'];
    $odeme_tutari = $_POST['payment_amount'];
    $sepet = $_POST['user_basket'];
    $kartsahibi = $_POST['cc_owner'];
    $kartno = $_POST['card_number'];
    $kartay = $_POST['expiry_month'];
    $kartyil = $_POST['expiry_year'];
    $kartcvv = $_POST['cvv'];
    $usern = $_POST['user_name'];
    $useradd = $_POST['user_address'];
    $usertel = $_POST['user_phone'];

    $user_basket = htmlentities(json_encode(array(
        array($sepet, $odeme_tutari, 1)
    )));
    
    
    print_r($_POST);
    
    $result = 1;
    return $result;
    
    ?>
android kotlin post
© www.soinside.com 2019 - 2024. All rights reserved.