http_post_fields
Returns the HTTP response(s) as string on success, or FALSE on failure.
Примеры
Пример #1 A http_post_fields() example
$fields = array(
‘name’ => ‘mike’ ,
‘pass’ => ‘se_ret’
);
$files = array(
array(
‘name’ => ‘uimg’ ,
‘type’ => ‘image/jpeg’ ,
‘file’ => ‘./profile.jpg’ ,
)
);
$response = http_post_fields ( «http://www.example.com/» , $fields , $files );
?>
Последние поступления:
Размещена 10 августа 2020 года
Я по ТВ видел, что через 10 лет мы будем жить лучше, чем в Германии.
Я не понял, что это они с Германией сделать хотят?!
ТехЗадание на Землю
Размещена 14 марта 2018 года
Пpоект Genesis (из коpпоpативной пеpеписки)
Шпаргалка по работе с Vim
Размещена 05 декабря 2017 года
Vim довольно мощный редактор, но работа с ним не всегда наглядна.
Например если нужно отредактировать какой-то файл например при помощи crontab, без знания специфики работы с viv никак.
Ошибка: Error: Cannot find a valid baseurl for repo
Размещена 13 сентабря 2017 года
Если возникает ошибка на centos 5 вида
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/
Linux Optimization
Размещена 30 июля 2012 года
http_post_fields
Returns the HTTP response(s) as string on success, or FALSE on failure.
Examples
Example #1 A http_post_fields() example
$fields = array(
‘name’ => ‘mike’ ,
‘pass’ => ‘se_ret’
);
$files = array(
array(
‘name’ => ‘uimg’ ,
‘type’ => ‘image/jpeg’ ,
‘file’ => ‘./profile.jpg’ ,
)
);
?php
$response = http_post_fields ( «http://www.example.com/» , $fields , $files );
?>
User Contributed Notes 4 notes
To use POST to submit a form to a site which requires a cookie for authentication you put the cookie in the $options array. Example:
$message = «RoboCodeDwarf now has the gold. \n\n» ;
$message .= «RoboCodeDwarf sez: [quote] » . ` fortune -s ` . «[/quote]\n» ;
$form_fields = array(
‘content’ => $message ,
‘add_signature’ => ‘add_it’ ,
‘submit’ => ‘Post reply’ );
$form_files =array();
$form_options =array( ‘cookies’ => array( ‘auth’ => $auth ) );
$response = http_post_fields ( $form_url , $form_fields , $form_files , $form_options );
$n = preg_match ( «/HTTP\/1.1 302 Found/» , $response , $matches );
if( $n < 1 ) echo "FAILED\n" ;
else echo «POSTED\n» ;
It was hard to figure out how to actually post files with this function. The «Array of files to post» is an array of associative arrays, each need the keys «name», «type» and «file». Consider this example code:
$files = array(
array(
‘name’ => ‘somename’ ,
‘type’ => ‘text/plain’ ,
‘file’ => $filename
)
);
$http_response = http_post_fields ( $url , $data , $files );
?>
comment to wormholio’s answer:
if you use regular expression, then use it fully:
«/HTTP\/\d\.\d 302 Found/»
Some servers still can use HTTP 1.0
Hear is an axmaple how to arrays as POST varibles:
$response = http_post_fields ( ‘http://example.com/page.php’ ,
array( ‘val[0]’ => ‘val1’ , ‘val[1]’ => ‘val2’ ));
- HTTP Functions
- http_cache_etag
- http_cache_last_modified
- http_chunked_decode
- http_deflate
- http_inflate
- http_build_cookie
- http_date
- http_get_request_body_stream
- http_get_request_body
- http_get_request_headers
- http_match_etag
- http_match_modified
- http_match_request_header
- http_support
- http_negotiate_charset
- http_negotiate_content_type
- http_negotiate_language
- ob_deflatehandler
- ob_etaghandler
- ob_inflatehandler
- http_parse_cookie
- http_parse_headers
- http_parse_message
- http_parse_params
- http_persistent_handles_clean
- http_persistent_handles_count
- http_persistent_handles_ident
- http_get
- http_head
- http_post_data
- http_post_fields
- http_put_data
- http_put_file
- http_put_stream
- http_request_body_encode
- http_request_method_exists
- http_request_method_name
- http_request_method_register
- http_request_method_unregister
- http_request
- http_redirect
- http_send_content_disposition
- http_send_content_type
- http_send_data
- http_send_file
- http_send_last_modified
- http_send_status
- http_send_stream
- http_throttle
- http_build_str
- http_build_url
http_post_fields
Возвращает строку с HTTP-ответом(ами) при успешном завершении работы, или FALSE при ошибке.
Примеры
Пример #1 Пример использования http_post_fields()
$fields = array(
‘name’ => ‘mike’ ,
‘pass’ => ‘se_ret’
);
$files = array(
array(
‘name’ => ‘uimg’ ,
‘type’ => ‘image/jpeg’ ,
‘file’ => ‘./profile.jpg’ ,
)
);?php
$response = http_post_fields ( «http://www.example.com/» , $fields , $files );
?>User Contributed Notes 4 notes
To use POST to submit a form to a site which requires a cookie for authentication you put the cookie in the $options array. Example:
$message = «RoboCodeDwarf now has the gold. \n\n» ;
$message .= «RoboCodeDwarf sez: [quote] » . ` fortune -s ` . «[/quote]\n» ;$form_fields = array(
‘content’ => $message ,
‘add_signature’ => ‘add_it’ ,
‘submit’ => ‘Post reply’ );
$form_files =array();
$form_options =array( ‘cookies’ => array( ‘auth’ => $auth ) );$response = http_post_fields ( $form_url , $form_fields , $form_files , $form_options );
$n = preg_match ( «/HTTP\/1.1 302 Found/» , $response , $matches );
if( $n < 1 ) echo "FAILED\n" ;
else echo «POSTED\n» ;It was hard to figure out how to actually post files with this function. The «Array of files to post» is an array of associative arrays, each need the keys «name», «type» and «file». Consider this example code:
$files = array(
array(
‘name’ => ‘somename’ ,
‘type’ => ‘text/plain’ ,
‘file’ => $filename
)
);
$http_response = http_post_fields ( $url , $data , $files );
?>comment to wormholio’s answer:
if you use regular expression, then use it fully:
«/HTTP\/\d\.\d 302 Found/»
Some servers still can use HTTP 1.0Hear is an axmaple how to arrays as POST varibles:
$response = http_post_fields ( ‘http://example.com/page.php’ ,
array( ‘val[0]’ => ‘val1’ , ‘val[1]’ => ‘val2’ ));- HTTP Функции
- http_cache_etag
- http_cache_last_modified
- http_chunked_decode
- http_deflate
- http_inflate
- http_build_cookie
- http_date
- http_get_request_body_stream
- http_get_request_body
- http_get_request_headers
- http_match_etag
- http_match_modified
- http_match_request_header
- http_support
- http_negotiate_charset
- http_negotiate_content_type
- http_negotiate_language
- ob_deflatehandler
- ob_etaghandler
- ob_inflatehandler
- http_parse_cookie
- http_parse_headers
- http_parse_message
- http_parse_params
- http_persistent_handles_clean
- http_persistent_handles_count
- http_persistent_handles_ident
- http_get
- http_head
- http_post_data
- http_post_fields
- http_put_data
- http_put_file
- http_put_stream
- http_request_body_encode
- http_request_method_exists
- http_request_method_name
- http_request_method_register
- http_request_method_unregister
- http_request
- http_redirect
- http_send_content_disposition
- http_send_content_type
- http_send_data
- http_send_file
- http_send_last_modified
- http_send_status
- http_send_stream
- http_throttle
- http_build_str
- http_build_url