English 中文(简体)
客户方能搞乱我的API吗?
原标题:Can client side mess with my API?
  • 时间:2012-05-27 19:35:28
  •  标签:
  • api
  • rest
  • soap

我有一个围绕两个用户之间交易的网站。 每个用户都需要同意相同的条件。 如果我要一个 API, 以便其他网站可以在自己的网站上执行, 那么我要确保其他网站无法通过增加与我应用程序无关的字段来干扰进程。 这是否可行?

问题回答

If I was to implement such a thing, I would allow other websites to use tokens/URLs/widgets that would link them to my website. So, for example, website X wants to use my service to agree user A and B on the same terms. Their page will have an embedded form/frame which would be generated from my website and user B will also receive an email with link to my website s page (or a page of website X with a form/frame generated from my server). Consider how different sites use eBay to enable users to pay. You buy everything on the site but when you are paying, either you are taken to ebay page and come back after payment, or the website has a small form/frame that is directly linked to ebay. But this is my solution, one way of doing it. Hope this helps.

它取决于您的 API 是如何执行的。 构建一个能真正获取任何类型数据的 API, 或者能够将额外的、命名的钥匙/价值配对作为字段的 API, 需要投入大量的工作、思考和工程。

如果您已经以这种方式实施了您的 API, 那么这个 API 的用户很有可能会使用它来扩展功能, 或者通过传递补充数据来构建稍有不同的东西 。

然而,如果您的 API 建于必须传递特定值的地方, 而这些字段是 required 的要求 < /em >, 那么使用您的 API 时就更加困难了, 其方式与您最初的初衷不同。

例如,谷歌有许多不同目的的API系统,每个API都有非常具体的参数,开发者必须使用这些参数才能成功满足HTTP的要求。 虽然这些API系统的目标是让allow 开发者扩展功能,但是它们只允许访问非常具体的部分数据。

最后, 您可以使用认证来防止未经授权访问您的 API 。 具体的执行细节主要取决于您正在工作的平台以及如何使用 API 。 例如, 如果用户必须登录使用您的 API 提供的服务, 那么某种形式的 OAuth 可能就足够了 。 但是, 如果其他服务器会消耗您的 API, 那么授权必须在 HTTP 信头中进行 。

关于API最佳做法的更多信息,见7 缩略图规则,当你建立一个API ,以及谷歌工程师题为的幻灯片,标题是:http://lcsd05.cs.tamu.edu/slides/keynote.pdf" rel=“no foolth” > 如何设计良好的API和为何重要





相关问题
Python SOAP server / client

I have a problem with Python and SOAP. I need to create a web service based on SOAP in Python. I read that I can use libraries like soaplib, suds and ZSI. I created a Hello World web service with ...

HTTP POST and complex structures

I m trying to send a complex HTTP POST request to a web service. The web service was created using VS2008, in which you can set VS to create HTTP POST and GET interfaces alongside the SOAP one. Now ...

XML-RPC Standard and XML Data Type

I was looking at XML-RPC for a project. And correct me if I m wrong, but it seems like XML-RPC has no XML datatype. Are you supposed to pass as a string? or something else? Am I missing something? ...

Most appropriate API for URL shortening service

I ve just finished an online service for shortening URLs (in php5 with Zend Framework); you can enter an URL and you get an short URL (like tinyurl and such sites). I m thinking about the API for ...

What is the best solution for creating a SOAP Server in PHP?

I need some advice on which library is the best choice when it comes to creating SOAP servers (and eventually SOAP clients) in PHP. I know there is built-in functions for this, but is that really the ...

Logging all Soap request and responses in PHP

Does anyone know how to log all request and responses with the builtin SoapClient in PHP? I could in fact manually log everything with SoapClient::__getLastRequest() and SoapClient::__getLastResponse()...

热门标签