REST API 实现示例代码
我对实现 API 一无所知。我确实了解一点 PHP。我遇到一种情况,需要调用 REST API 方法来清除 CDN 服务器上的缓存。有人可以帮我一些示例代码吗?
以下是示例请求:
PUT <<url>>
Authorization: TOK:12345-12345
Accept: application/json
Content-Type: application/json
Host: api.edgecast.com
Content-Length: 87
{
"MediaPath":"<<urlhere>>"
"MediaType":"3"
}
有人可以帮我编写代码来实现此 REST API 请求吗? 提前致谢。
I know nothing about implementing an API. I do know PHP a bit. I have a situation where I need to call a REST API method to purge cache on a CDN server. Can somebody help me with some sample code?
The following is the sample request:
PUT <<url>>
Authorization: TOK:12345-12345
Accept: application/json
Content-Type: application/json
Host: api.edgecast.com
Content-Length: 87
{
"MediaPath":"<<urlhere>>"
"MediaType":"3"
}
Can somebody help me with code to implement this rest api request?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我也必须找到困难的方法。这已经过测试(对我的原始代码稍作修改)
I had to find the hard way too. This has been tested (with slight modifications from my original code)
懒得从头开始写,所以从 令人惊叹的粉红色网站,谷歌在结果的第一页建议。
PS:源搜索请求:http://www.google。 ru/search?q=php+sample+put+request+curl
Was too lazy to write from the scratch so copied from amazingly pink site that Google advises in the first page of results.
PS: The source search request: http://www.google.ru/search?q=php+sample+put+request+curl
这里是我完全实现的 Grunt 任务的源要点,供其他人思考关于使用 EdgeCast API。您会在我的示例中发现,我使用节点模块来执行清除 CDN 的curl 命令。
这是我花了几个小时尝试让 HTTP 请求在 Node.js 中工作后得到的结果。我能够让一个在 Ruby 和 Python 中工作,但没有满足这个项目的要求。
Here is my source gist for my fully implemented Grunt task for anyone else thinking about working with the EdgeCast API. You'll find in my example that I use a node module to execute the curl command which purges the CDN.
This was that I ended up with after spending hours trying to get an HTTP request to work within Node. I was able to get one working in Ruby and Python, but did not meet the requirements of this project.