他会提供相应接口给你的,具体调用方法就相当于讲求某个链接。 如: http://localhost/operate.php?act=get_user_list&type=json 在这里operate.php相当于一个接口,其中get_user_list 是一个api(获取用户列表),讲求返回的数据类型为json格式。 你只需要在你php代码中执行这条链接他就会返回。 get方式的直接使用 $file_contents = file_get_content('http://localhost/operate.php?act=get_user_list&type=json') post方式得用下面的(需要开启php curl支持)。 $url = 'http://localhost/operate.php?act=get_user_list&type=json'; $ch = curl_init (); curl_setopt ( $ch, curlopt_url, $url ); curl_setopt ( $ch, curlopt_returntransfer, 1 ); curl_setopt ( $ch, curlopt_connecttimeout, 10 ); curl_setopt ( $ch, curlopt_post, 1 ); //启用post提交 $file_contents = curl_exec ( $ch ); curl_close ( $ch );
相关推荐:
php之api接口入门详解
php服务器端的api以及接口开发详解
php进行api接口测试
以上就是php调用接口api的方法的详细内容。
