How to create your own API with ACL in magento

Source: Internet
Author: User

Finally, I got my customize API works with magento today. I was confusing by the complex configuration XML files in magento, here I post my example which might be helpful though.

This example passed testing under magento ver 1.3.2.4 using XML-RPC in. NET platform.

 

Steps:

1./APP/etc/modules/hanix_all.xml

1 <? XML version = "1.0" ?>
2 < Config >
3 < Modules >
4 < Hanix_customize >
5 < Active > True </ Active >
6 < Codepool > Local </ Codepool >
7 </ Hanix_customize >
8 </ Modules >
9 </ Config >

 

 

2./APP/code/local/hanix/

 

3./APP/code/local/hanix/customize/etc/config. xml

1 <? XML version = "1.0" ?>
2 < Config >
3
4 < Modules >
5 < Hanix_customize >
6 < Version > 0.1.0 </ Version >
7 </ Hanix_customize >
8 </ Modules >
9
10 < Global >
11
12 < Models >
13 < Customize >
14 < Class > Hanix_customize_model </ Class >
15 </ Customize >
16 </ Models >
17
18 </ Global >
19
20 </ Config >

 

 

4./APP/code/local/hanix/customize/etc/API. xml

1 <? XML version = "1.0" ?>
2 < Config >
3 < API >
4
5 < Resources >
6 < Customize_api Translate = "Title" Module = "Customize" >
7
8 < Title > Customize Resource </ Title >
9 < Model > Customize/API </ Model >
10 < ACL > Customize </ ACL >
11
12 < Methods >
13 < Test Translate = "Title" Module = "Customize" >
14 < Title > Test Method </ Title >
15 < ACL > Customize/test </ ACL >
16 </ Test >
17 </ Methods >
18
19 </ Customize_api >
20 </ Resources >
21
22 < ACL >
23 < Resources >
24 < Customize Translate = "Title" Module = "Customize" >
25 < Title > Customize APIs </ Title >
26 < Sort_order > 1 </ Sort_order >
27 < Test Translate = "Title" Module = "Customize" >
28 < Title > Test API </ Title >
29 </ Test >
30 </ Customize >
31 </ Resources >
32 </ ACL >
33
34 </ API >
35 </ Config >

 

 

 

5./APP/code/local/hanix/customize/model/API. php

1 <? PHP
2
3 Class Hanix_customize_model_api Extends Mage_api_model_resource_abstract
4 {
5 Public   Function Test ()
6 {
7 Return   " Hello test... " ;
8 }
9 }

 

 

OK! That are the five steps What You Need To Be Done. and don't forget to refresh the magento cache or just simply disable it. now go to magento backend: System/Web Service/roles. your API will be there.

 

Now, you can create an web service account to perform test. I used my own XML-RPC API showed below:

 

As can be seen, string "Hello test..." returns correctly.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.