PHP给第三方接口POST或GET方式传输数据并得到返回值

来源:互联网 发布:指南针软件 不断打电话 编辑:程序博客网 时间:2024/06/06 01:38

function Post($url, $post = null){     $context = array();     if (is_array($post))     {         ksort($post);         $context['http'] = array         (                'timeout'=>60,             'method' => 'POST',             'content' => http_build_query($post, '', '&'),         );     }     return file_get_contents($url, false, stream_context_create($context));}$data = array(     'name' => 'test',     'email' => 'test@gmail.com',     'submit' => 'submit',);echo Post('http://www.baidu.com', $data);


1 0
原创粉丝点击