/**
     * POST URL
     * @param $url
     * @param null $post
     * @return false / string
     */
    public static function UrlPost($url, $post = null, $timeout = 3) {
        if (is_array($post)) {
            ksort($post);
            $content = http_build_query($post);
            $content_length = strlen($content);
            $options = array(
                'http' => array(
                    'method' => 'POST',
                    'timeout' => ($timeout ? $timeout : 3),
                    'header' =>
                        "Content-Type: application/x-www-form-urlencoded\r\n" .
                        "Content-Length: $content_length\r\n",
                    'content' => $content
                )
            );
            return file_get_contents($url, false, stream_context_create($options));
        }
        return false;
    }

file_get_contents抓取远程URL内容代码示例

 

相关文章:

  • 2022-02-11
  • 2021-08-21
  • 2022-12-23
  • 2021-10-22
  • 2022-03-09
猜你喜欢
  • 2021-08-16
  • 2022-12-23
  • 2021-08-16
  • 2022-01-03
  • 2021-11-29
  • 2021-04-26
相关资源
相似解决方案