vincet / url-opener
此包已被弃用且不再维护。未建议替代包。
PHP 5.3 的 URL 打开器
dev-master
2013-01-12 18:18 UTC
Requires
- php: >= 5.3.0
This package is auto-updated.
Last update: 2023-07-27 08:52:15 UTC
README
通过 HTTP 加载网页的库。它支持 GET 和 POST 请求以及处理 Cookie 管理。
<?php require_once 'path/to/UrlOpener/src/autoload.php'; use VinceT\UrlOpener\UrlOpener; use VinceT\UrlOpener\Http\Header\RequestHeaderBag; // use config to set specific options // default values are: $config = array( 'USE_CURL' => false, // set to true to use curl instead of file_get_contents 'USE_IP' => false, // if you want to make requests from a specific IP, give the ip address to use 'COOKIE_FILE' => null, // if you want to store cookies into a file, give the file name ); $urlOpener = new UrlOpener($config); $postDatas = array( 'my_var' => 'the value', ); $headers = new RequestHeaderBag(); $headers->setUserAgent('My user agent string'); $response = $urlOpener->open('http://www.example.com', $postDatas, $headers); print $response->getContent();