aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-09-16 20:46:44 -0700
committerfriendica <info@friendica.com>2014-09-16 20:46:44 -0700
commit53d0e855dfaeccfebd55d0b3c91cf040b2e317a4 (patch)
tree793c0bb49f722aac2b7ee3197a8e43cf6059e5e2 /include
parentce36e8a8bb9ab5a96e395272e2045f3e6563666c (diff)
downloadvolse-hubzilla-53d0e855dfaeccfebd55d0b3c91cf040b2e317a4.tar.gz
volse-hubzilla-53d0e855dfaeccfebd55d0b3c91cf040b2e317a4.tar.bz2
volse-hubzilla-53d0e855dfaeccfebd55d0b3c91cf040b2e317a4.zip
z_post_url_json() added to easily deal with JSON post APIs; without getting content-type unknown warnings/errors. Also added a debug option to z_get|post_url so you could track and log some of these nasty little buggers.
Diffstat (limited to 'include')
-rw-r--r--include/network.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/network.php b/include/network.php
index e84ea91f4..7286f0b12 100644
--- a/include/network.php
+++ b/include/network.php
@@ -124,6 +124,10 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
}
$ret['body'] = substr($s,strlen($header));
$ret['header'] = $header;
+
+ if(x($opts,'debug')) {
+ $ret['debug'] = $curl_info;
+ }
@curl_close($ch);
return($ret);
@@ -251,11 +255,24 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
$ret['body'] = substr($s,strlen($header));
$ret['header'] = $header;
+
+ if(x($opts,'debug')) {
+ $ret['debug'] = $curl_info;
+ }
+
+
curl_close($ch);
return($ret);
}
+function z_post_url_json($url,$params,$redirects = 0, $opts = array()) {
+
+ $opts = array_merge($opts,array('headers' => array('Content-Type: application/json')));
+ return z_post_url($url,json_encode($params),$redirects,$opts);
+
+}
+
function json_return_and_die($x) {
header("content-type: application/json");