800M

11 object(s)
 

PHP发送POST请求调用API借口

function send_post($url, $post_data) {
    $postdata = http_build_query($post_data);
    $options = array(
            'http' => array(
            'method' => 'POST',
            'header' => 'Content-type:application/x-www-form-urlencoded',
            'content' => $postdata,
            'timeout' => 15
        )
    );
    $context = stream_context_create($options);
    return file_get_contents($url, false, $context);
}

$post_data = array(
    'domain' => '800m.net',
    'body' => 'Hello World!'
);

$str = send_post('http://www.800m.net/api.php', $post_data);