<?php 2 $ch = curl_init(); 3 $url = 'http://localhost/jsonrpc?tm='.time().mt_rand (100,999); //参数是为了防止缓存 4 $options = array( 5 CURLOPT_URL => $url, 6 CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0", 7 CURLOPT_RETURNTRANSFER => 1, 8 ); 9 curl_setopt_array($ch, $options); 10 #JSON 示例数据 11 curl_setopt($ch, CURLOPT_POSTFIELDS, '{"jsonrpc":"2.0","method":"getOpt","id":1}'); 12 13 $html=curl_exec($ch); 14 $info = curl_getinfo($ch); #获取请求的详细信息 用于调试 15 curl_close($ch); 16 var_dump($html);
curl 实现json-rpc 服务
最新推荐文章于 2022-09-29 10:22:33 发布