gpt4 book ai didi

android - 将 post 数组改造为 php 文件

转载 作者:行者123 更新时间:2023-11-30 05:12:01 24 4
gpt4 key购买 nike

我可以使用这段代码将我的数据发布到 php 文件

Strint senddata = "apple";
Call<DataResponse> call_datas = apiService.getallData(senddata);
call_datas.enqueue(new Callback<DataResponse>() {
@Override
public void onResponse(Call<DataResponse>call, Response<DataResponse> response) {
try{
List<mDatas> mlist = response.body().getResults();
all_recycler.setAdapter(new TestAdapter(mlist, mContext));
}catch (Exception e){ }
}
@Override
public void onFailure(Call<DataResponse>call, Throwable t) {

}
});

接口(interface)接口(interface).java

public interface ApiInterface {
@GET("/test.php")
Call<DataResponse> getallData(@Query("key") String key);
}

但我想将数组列表发送到我的 php 文件。如何通过改造将字符串数组发送到 php 文件?示例字符串数组:

String[] senddata= {"apple","banana","peach"}

最佳答案

您只需更改 ApiInterface.java 文件即可。

public interface ApiInterface {
@FormUrlEncoded
@GET("/test.php")
Call<DataResponse> getallData(@Field("key") String[] key);
}

希望对您有所帮助。

关于android - 将 post 数组改造为 php 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53567404/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com