使用亚马逊MWS(库存API)与codeIgniter(PHP) [英] Using Amazon MWS (Inventory API) with CodeIgniter (PHP)

查看:2086
本文介绍了使用亚马逊MWS(库存API)与codeIgniter(PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点熟悉使用亚马逊MWS API,但是,我是新来的codeIgniter和整个HMVC事情。我很好奇,我怎么会添加API到codeIgniter。我会仔细分析整个API到相应的MVC文件夹,或者可能我只是将其添加为一个库。如果是后者的话,我将如何使用API​​?

I'm somewhat familiar with using the Amazon MWS apis, but I'm new to CodeIgniter and the whole hmvc thing. I'm curious how I would add the api into CodeIgniter. Would I have to dissect the entire api into the appropriate mvc folders, or could I just add it as a library. If the latter is the case, how would I use the api?

我很抱歉,如果这是模糊的,但我将不胜AP preciate任何帮助,你愿意来!谢谢

I'm sorry if this is vague, but I would greatly appreciate any help you're willing to offer! Thanks

推荐答案

我不能说具体到codeIgniter anthing,但我已经对各种MVC库的工作,这样我就可以给出一个概述。选项​​有:

I cannot say anthing specific to CodeIgniter, but I've worked with various MVC libraries, so I can give a general overview. Your options are:

I)从头开始写一个模型

新的code访问MWS将主要结束在模式的空间。该控制器和视图(这你可能最终需要)是的code,亚马逊提供的范围之内,所以他们需要被写入反正。至于MVC(和OOP)的想法去,这是正确的方式做到这一点,你可以充分利用继承和多态的。

New code accessing the MWS would mostly end up in the "Model" space. The controllers and views (which you'll probably eventually need) are outside the scope of the code that Amazon provides, so they need to be written anyways. As far as the MVC (and OOP) idea goes, this is the "proper" way to do it, you can make full use of inheritance and polymorphism.

优点:您的模型访问MWS会按照你的MVC框架的规则和准则。这将是容易集成到框架的其他部分,并具有很好的code中的其余部分集成在一起。

Advantages: Your model accessing the MWS will follow the rules and guidelines of your MVC framework. It will be easy to integrate into other parts of the framework, and integrate nicely with the rest of the code.

缺点:大量的code编写和(更重要的是,由于MWS是一个移动的目标)保持

Disadvantages: lots of code to write and (more importantly, since MWS is a moving target) maintain.

二)使用亚马逊的code作为一个库

亚马逊的code将进入库的空间。因为它不符合你的MVC框架的规则,它会感觉陌生的code中的其余部分。

Amazon's code would go into the "Libraries" space. As it doesn't follow the rules of your MVC framework, it will "feel" foreign to the rest of the code.

优点:减code编写和维护

Advantages: Less code to write and maintain.

缺点:框架,没有code重用,没有继承和多态无无使用

Disadvantages: No usage of the framework, no code reuse, no inheritance and no polymorphism.

三)写一个包装

这基本上是两种选择上述的混合。你写周围的库(进入模型空间),其中要求未修改亚马逊库非常薄的包装。正确写入,你可能会得到一个两全其美 - 这取决于多少接口库符合您的需求模型接口

This is basically a mix of the two options above. You write a very thin wrapper around the library (goes into the Model space) which calls the unmodified Amazon library. Written properly, you might get a "best of both worlds" - this depends on how much the interface the library matches your desired model interface.

优点:通常只有很少的额外code是需要的,当相比,库的方法,而模型可以用来以相同的方式作为一个完整的重写

Advantages: Often only little extra code is needed, when compared to the "library" approach", while the model can be used in the same way as a complete rewrite.

缺点:有时需要几乎同样多的code是从头开始编写。

Disadvantages: Sometimes needs almost as much code as writing from scratch.

的建议和意见

我的做法很可能会去同一个包装,除非我需要的库的code只是一小部分。由于PHP没有一个严格的对象层次结构,它通常是可能正确地模仿继承反正如果需要的话。

My approach would probably be to go with a wrapper, unless I need just a fraction of the library's code. Since PHP does not have a strict object hierarchy, it is usually possibly to properly mimic inheritance anyways if needed.

在设计围绕MWS模型旁注:与大多数网络服务,一些调用MWS API(如SubmitFeed)异步工作在大约一个操作的成功或失败的信息将只提供分钟(甚至小时)呼叫已被制成之后。大多数MVC模式的层次结构和接口不是设计来处理这种类型的东西好,所以完全重写可能不给你,你会通常会得到好处。

A side note on designing a model around the MWS: Unlike most web services, some calls to the MWS API (e.g. SubmitFeed) work asynchronously in that information about the success or failure of an operation will only be available minutes (or even hours) after the call has been made. Most MVC model hierarchies and interfaces are not designed to handle that type of thing well, so a complete rewrite might not give you the benefits that you'd normally get.

请记住,我没有约codeIgniter知识。你的情况可能会有所不同。

Please remember, that I have no knowledge about CodeIgniter. Your mileage may vary.

这篇关于使用亚马逊MWS(库存API)与codeIgniter(PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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