android - Retrofit API的GET
PHP中文网
PHP中文网 2017-04-17 17:50:26
0
1
463

https://api.heweather.com/x3/weather?cityid=城市ID&key=XXXXXXXXX
这种API 如何用Retrofit 来书写呢

     @GET("x3/weather?cityid={cityid}&key={apikey}")
    Call<WeatherResult> WeatherGet(@Path("cityid") String id,@Path("apikey") String key);
这样写 被提示要使用`@Query("cityid") String id`

Call<WeatherResult> WeatherGet(@Query("cityid") String id,@Path("apikey") String key);


修改完后 又被提示 Path 不能放在 Query后面

那么我想问这样的API 如何写呢

PHP中文网
PHP中文网

认证高级PHP讲师

全員に返信(1)
阿神

https://futurestud.io/tutoria... これによると、次のように書く必要があります

リーリー

ここで path を使用できないのはなぜですか? ここでは api_key がクエリ文字列として使用されるため、query は階層ファイル パスを表すためです。 path参考リソース
https://zh.wikipedia.org/wiki...

いいねを押す +0
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!