Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of writing interface in phpcms api

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how to write interfaces for phpcms api. Xiao Bian thinks it is quite practical, so share it for everyone to make a reference. Let's follow the editor and have a look.

How to write phpcms api interface?

Recently, I developed a crm system, thinking that if I can sell it in the future, can I dynamically call the recommended information of my website in the interface, which is regarded as an advertisement! So I tried to develop a simple api interface with phpcms

phpcms v9 development simple api interface (applicable to white!)

phpcms v9 api interfaces are stored in api folder, access path is www.XXX.com/api.php? op=count&....., The other op=count is for your specific api file, so I started developing according to this rule!

(1) Step 1: Create the file demo.php under the api folder of the website, code:

(2) Use Ajax to send requests on the request-side page

$(function(){$.ajax({url:'http://www.XXX.com/api.php? op=demo&catid=28&num= 10', dataType:'jsonp',//jsonp Typejsonp:"jsoncallback", //callback type:' get', success:function(data){var data=eval(data); //Convert to json object $.each(data, function(index, p){html = "";html += ""+ p.title +"";html += "";$("#test").append(html); //append to id=test div})},error : function() {console.log ('fail ');}});});});

OK done! This can have cross-domain call their own website inside things!

The effect browsing is as shown in the figure:

Thank you for reading! About phpcms api write interface method to share here, hope the above content can have some help to everyone, so that we can learn more knowledge. If you think the article is good, you can share it so that more people can see it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report