在php中调用接口以及编写接口
在php中调用接口以及编写接口如:http://localhost/openUser.php?act=get_user_list&type=json 在这里openUser.php相当于一个接口,其中get_user_list 是一个API(获取用户列表),讲求返回的数据类型为JSON格式。 你只需要在你PHP代码中执行这条链接他就会返回。GET方式的直接使用 $file_contents = file_get_content('http://localhost/openUser.php?act=get_user_list&type=json') POST方式得用下面的(需要开启PHP curl支持)。 $url = 'http://localhost/openUser.php?act=get_user_list&type=json';$ch = curl_init ();curl_setopt ( $ch, CURLOPT_URL, $url );curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );curl_setop...