From 0fb22e1284c0510a0d009e34b7a1aa31ef6be052 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 20 Feb 2012 01:53:22 +0100 Subject: API is now working on my nginx server. --- include/api.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'include/api.php') diff --git a/include/api.php b/include/api.php index 7b8709659..a621f1aa7 100755 --- a/include/api.php +++ b/include/api.php @@ -99,6 +99,10 @@ **************************/ function api_call(&$a){ GLOBAL $API, $called_api; + + // preset + $type="json"; + foreach ($API as $p=>$info){ if (strpos($a->query_string, $p)===0){ $called_api= explode("/",$p); @@ -109,14 +113,14 @@ load_contact_links(local_user()); - logger('API call for ' . $a->user['username'] . ': ' . $a->query_string); + logger('API call for ' . $a->user['username'] . ': ' . $a->query_string); logger('API parameters: ' . print_r($_REQUEST,true)); - $type="json"; + $type="json"; if (strpos($a->query_string, ".xml")>0) $type="xml"; if (strpos($a->query_string, ".json")>0) $type="json"; if (strpos($a->query_string, ".rss")>0) $type="rss"; - if (strpos($a->query_string, ".atom")>0) $type="atom"; - + if (strpos($a->query_string, ".atom")>0) $type="atom"; + $r = call_user_func($info['func'], $a, $type); if ($r===false) return; @@ -126,8 +130,8 @@ header ("Content-Type: text/xml"); return ''."\n".$r; break; - case "json": - //header ("Content-Type: application/json"); + case "json": + //header ("Content-Type: application/json"); foreach($r as $rr) return json_encode($rr); break; @@ -139,7 +143,7 @@ header ("Content-Type: application/atom+xml"); return ''."\n".$r; break; - + } //echo "
"; var_dump($r); die();
 			}
@@ -150,8 +154,8 @@
 				header ("Content-Type: text/xml");
 				return ''."\n".$r;
 				break;
-			case "json": 
-				header ("Content-Type: application/json");  
+			case "json":
+				header ("Content-Type: application/json");
 			    return json_encode(array('error' => 'not implemented'));
 				break;
 			case "rss":
@@ -162,7 +166,6 @@
 				header ("Content-Type: application/atom+xml");
 				return ''."\n".$r;
 				break;
-				
 		}
 	}
 
-- 
cgit v1.2.3


From e2f276881ee31d56f244950f231fffbf935f7f0d Mon Sep 17 00:00:00 2001
From: Michael 
Date: Mon, 20 Feb 2012 11:15:22 +0100
Subject: Some testing stuff

---
 include/api.php | 1 +
 1 file changed, 1 insertion(+)

(limited to 'include/api.php')

diff --git a/include/api.php b/include/api.php
index a621f1aa7..1d3e5c186 100755
--- a/include/api.php
+++ b/include/api.php
@@ -148,6 +148,7 @@
 				//echo "
"; var_dump($r); die();
 			}
 		}
+		logger('API call not implemented: '.$a->query_string." - ".print_r($_REQUEST,true));
 		$r = 'not implemented';
 		switch($type){
 			case "xml":
-- 
cgit v1.2.3