在改造URL终点 [英] End Point in Retrofit URL

查看:182
本文介绍了在改造URL终点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中使用改造。我宣布接口,但我不知道如何在这个网址使用端点。

in my application using Retrofit. I had declared interface, But I am not sure how to use Endpoint in this url.

我的网址是: http://javatechig.com/api/get_category_posts/?dev=1&slug=android

现在我的问题是如何添加端点这个网址。我的界面是这样的:

Now my question is how to add endpoint for this url. my interface is like:

public interface Api {

@GET("/WHAT COMES HERE")
void getItem(WHAT_COMES HERE,
                Callback<FeedItem> callback);

}

任何建议将AP preciated先谢谢

Any suggestion will be appreciated Thanks in advance

推荐答案

端点,这将是为大家服务的URL(在大多数情况下)相同的URL的一部分。例如:假设Facebook是给人一种服务,那么它的终点是会像 http://www.facebook.com/ ,然后你可以添加任何请求POST / GET通过添加USER_NAME或PAGE_NAME//只是一个例子。

ENDPOINT is the part of the URL which will be the same for all services URLs (in most cases). Eg: suppose facebook is giving a service, then its ENDPOINT is going to be like "http://www.facebook.com/" and then you can add any request POST/GEt by add "user_name OR page_name" //Just an example.

所以,你需要做的设定结束点是什么是一样的东西:

So what you need to do to set the end point is something like:

END_POINT =htt​​p://javatechig.com/api/get_category_posts/;

,然后用它喜欢的:

Builder builder = new RestAdapter.Builder().setEndpoint(END_POINT);
...
...
@GET("?dev=1&slug=android")

希望它帮助。

这篇关于在改造URL终点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆