Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function post($url = null, $params = null, $ref = null, $headers = null, $proxy = null) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 10);
- curl_setopt($ch, CURLOPT_REFERER, $ref);
- if($headers) {
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- }
- if($params) {
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
- }
- if($proxy) {
- curl_setopt($ch, CURLOPT_PROXY, $proxy);
- }
- $result = curl_exec($ch);
- curl_close($ch);
- return $result;
- }
- /*
- Запрос без параметров (GET)
- echo post('http://vk.com');
- GET запрос
- echo post('http://vk.com?param1=value1¶m2=value2');
- POST запрос
- echo post('http://vk.com', 'param1=value1¶m2=value2');
- Сложный запрос:
- echo post('http://vk.com', 'param1=value1¶m2=value2', 'http://google.ru', array(
- 'Content-type: text/plain',
- 'Content-length: 100'
- ), 'ip:port');
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement