gpt4 book ai didi

android - 在照片引用和 key 的帮助下使用改造库获取 body 响应中的照片

转载 作者:行者123 更新时间:2023-11-29 19:16:14 25 4
gpt4 key购买 nike

 String photoReference = imageDataObject.getPhotoReference();
String width = imageDataObject.getWidth();
String height = imageDataObject.getHeight();
ApiInterface apiServicePhoto = ApiClient.getClient(GlobalConstant.BASE_URL_PHOTO).create(ApiInterface.class);
Call<ResponseBody> callPhoto = apiServicePhoto.getSinglePhoto(GlobalConstant.MAX_WIDTH_IMAGE, photoReference, GlobalConstant.API_KEY);
callPhoto.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
Log.e(TAG, "onResponse: " + response);
if (response.isSuccessful()) {
if (response.body() != null) {
Log.e(TAG, "onResponse: ");
}
Log.e(TAG, "onResponse: " + response.body());
}
}

@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Log.e(TAG, "onFailure: ");
}
});

//API接口(interface)

  @GET("photo")
Call<ResponseBody> getSinglePhoto(@Query("maxwidth") Integer maxwidth, @Query("photoreference") String photoreference, @Query("key") String key);

//API客户端

public class ApiClient {
private static Retrofit retrofit = null;
public static Retrofit getClient(String baseUrlRestro) {
if (retrofit == null) {
retrofit = new Retrofit.Builder()
.baseUrl(baseUrlRestro)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;
}

//基本网址

public static final String BASE_URL_PHOTO = "https://maps.googleapis.com/maps/api/place/";

我正在尝试这段代码,但我无法在响应正文中获得任何内容。正文始终为空。有没有办法使用照片引用来获取照片。

提前致谢

最佳答案

Glide 对我来说工作正常。我在这里为您发布代码。

ImageView ivPhoto = (ImageView) findViewById(R.id.ivPhoto);
String url = "https://maps.googleapis.com/maps/api/place/photo" +
"?maxwidth=400" +
"&photoreference=CnRtAAAATLZNl354RwP_9UKbQ_5Psy40texXePv4oAlgP4qNEkdIrkyse7rPXYGd9D_Uj1rVsQdWT4oRz4QrYAJNpFX7rzqqMlZw2h2E2y5IKMUZ7ouD_SlcHxYq1yL4KbKUv3qtWgTK0A6QbGh87GB3sscrHRIQiG2RrmU_jF4tENr9wGS_YxoUSSDrYjWmrNfeEHSGSc3FyhNLlBU" +
"&key=AIzaSyAfDHQhe4fmz5FAitOnTjrOFPesb88GXFE";

Glide.with(this)
.load(url)
.into(ivPhoto);

关于android - 在照片引用和 key 的帮助下使用改造库获取 body 响应中的照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43434630/

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