Functions
WebDev/*nix assorted functions & hacks
Search
find all
Array
-
Bash
-
Classes
-
Config
-
DateTime
-
Debug
-
dotjs
-
File
-
foooo
-
Git
-
HTML
-
Images
-
Javascript
-
Linux
-
Math
-
Misc
-
MySQL
-
OS X
-
Reading
-
Redis
-
Shell scripts
-
snippets
-
SQL
-
Strings
-
TextMate
-
Web
-
\(^o^)/ Fun!
-
_Misc hacks
-
_Pages
Web
curl_get($url, $raw=false)
httppost($url, $data)
http_build_query($array) & http_raw_query
http_raw_query($formdata, ..)
4
found
auth
Name:
Category: Web
Body:
#________________________, # httppost($url, $data) / function httppost($url, $data) { if (strpos($url, 'http://') !== 0) $url = 'http://'. ltrim($url, '/'); $data = http_build_query($data); # creates url-encoded name=param&.. string $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $res = curl_exec($ch); curl_close($ch); if ($res) { $body = substr(strstr($res, "\r\n\r\n"), 4); $headers = substr($res, 0, strpos($res, "\r\n\r\n")); $status = explode(' ', $headers); $status = (int) $status[1]; return array($status, $body, $headers); }else{ printStyle('httppost() error, probably curl', 'red'); return false; } }
Footer