Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

调用RESTful API的时候怎么拼接参数 #37

Closed
kingstal opened this issue Sep 20, 2017 · 6 comments
Closed

调用RESTful API的时候怎么拼接参数 #37

kingstal opened this issue Sep 20, 2017 · 6 comments

Comments

@kingstal
Copy link

您好,我现在在项目中使用CTNetworking进行接口调用,目前采取的还是传统的方式,调用方提供参数字典,将参数字典按键值对的形式拼接在methodName的后面用问号分隔作为query,组成完整的url。

现在项目改造,统一采用RESTful API,想请教一下这种情况下该怎么去构造url。

@casatwy
Copy link
Owner

casatwy commented Sep 20, 2017

在-methodname里面可以使用self.paramSource获取参数然后拼接

@kingstal
Copy link
Author

-methodname里调用self.paramSource获取参数拼接完后之后,是不是也应该在manager的reformParams方法中返回一个空字典,这样在最后生产request的时候才会是正确的request ?

@casatwy
Copy link
Owner

casatwy commented Sep 21, 2017

无所谓的,paramSource的内容是只会放入body的,你现在的做法就是再挂到URL上而已

@kingstal
Copy link
Author

我debug看了一下,发送get请求的时候,是会把-reformParams 方法返回的字典生成string作为query挂到URL后面的

@casatwy
Copy link
Owner

casatwy commented Sep 22, 2017 via email

@kingstal
Copy link
Author

好的,非常感谢,问题已经解决。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants