php开发api接口的实例网址:http://wk.yl1001.com/doc_8771381808343778_all.htm
分享一例php实现API接口的代码,实现用户的注册、登录、查询用户信息的功能,是学习PHP API开发的不错实例,有兴趣的朋友研究下吧。
PHP API接口的服务端部分
代码示例:
<?php
/**
*三目
* PHP开发API接口 服务端
*/
require 'conn.php';
header('Content-Type:text/html;charset=utf-8');
$action = $_GET['action'];
switch ($action) {
//注册会员
case"adduserinfo";
$username = lib_replace_end_tag(trim($_GET['username']));
$password2 = lib_replace_end_tag(trim($_GET['userpassword']));
$password = md5("$password2" . ALL_PS);
$email = lib_replace_end_tag(trim($_GET['email']));
if ($username == '' || $password2 == '' || $password == '') {
$res = urlencode("参数有误");
exit(json_encode($res)); //有空信息
}
$sql = "select username from `member` where username='$username'";
$query = mysql-query.h