简体   繁体   English

消耗外部API

[英]Consuming external API

I'm a PHP developer, learning Umbraco and ASP.NET. 我是一名PHP开发人员,正在学习Umbraco和ASP.NET。 I consumed an external API before using Guzzle in Laravel, however everything I found so far on Umbraco is very different to what I'm used to. 在Laravel中使用Guzzle之前,我使用了外部API,但是到目前为止,我在Umbraco上发现的所有内容与我以前所用的都非常不同。

Now I'd like to consume external API in Umbraco, and return JSON objects into views. 现在,我想在Umbraco中使用外部API,并将JSON对象返回到视图中。 For example, one JSON object is an event (a concert or a sport event) which contains values like image, date, description. 例如,一个JSON对象是一个事件(音乐会或体育赛事),其中包含诸如图像,日期,描述之类的值。 These will be passed into a view. 这些将传递到视图中。 I should be able to do this once I wrap my head around how to consume the API. 一旦我全神贯注于如何使用API​​,就应该能够做到这一点。

How would I consume external API on Umbraco? 我如何在Umbraco上使用外部API? I'm unsure where to start. 我不确定从哪里开始。 Are there any good tutorials available out there? 有没有好的教程?

On server side you can look at this library Restsharp that helps you to consume external http or rest api. 在服务器端,您可以查看此库Restsharp ,该库可帮助您使用外部http或rest api。 You can easily install it via nuget. 您可以通过nuget轻松安装它。

For client side you can use JQuery to do Ajax call but need to take into considering CORS . 对于客户端,您可以使用JQuery进行Ajax调用,但需要考虑CORS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM