]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
init and end documents
authorEvan Prodromou <evan@prodromou.name>
Fri, 18 Jul 2008 04:34:56 +0000 (00:34 -0400)
committerEvan Prodromou <evan@prodromou.name>
Fri, 18 Jul 2008 04:34:56 +0000 (00:34 -0400)
darcs-hash:20080718043456-84dde-ffe825e8021e0f803fbbecacdc93d26309853daa.gz

actions/twitapifriendships.php
lib/twitterapi.php

index a8de77107ad4538baa9b7d159f70d99c80a4f426..1ea8199e9ce63bc8ffdced33ccd87e282354aa29 100644 (file)
@@ -32,6 +32,7 @@ class TwitapifriendshipsAction extends TwitterapiAction {
 
                if (!$other) {
                        $this->client_error(_('No such user'));
+                       exit();
                        return;
                }
                
@@ -39,6 +40,7 @@ class TwitapifriendshipsAction extends TwitterapiAction {
                
                if ($user->isSubscribed($other)) {
                        $this->client_error(_('Already subscribed.'));
+                       exit();
                        return;
                }
                
@@ -50,14 +52,16 @@ class TwitapifriendshipsAction extends TwitterapiAction {
 
                if (!$result) {
                        $this->server_error(_('Could not subscribe'));
+                       exit();
                        return;
                }
                
                mail_subscribe_notify($other, $user);
 
-               common_start_xml();
+               $type = $apidata['content-type'];
+               $this->init_document($type);
                $this->show_profile($other);
-               common_end_xml();
+               $this->end_document($type);
                exit();
        }
        
@@ -90,9 +94,10 @@ class TwitapifriendshipsAction extends TwitterapiAction {
                        $sub->delete();
                }
 
-               common_start_xml();
+               $type = $apidata['content-type'];
+               $this->init_document($type);
                $this->show_profile($other);
-               common_end_xml();
+               $this->end_document($type);
                exit();
        }
 
index b8640fa5903e2b99caae0c35bb64f4ebbb5c0493..f61ba9b671b58f52049219c8b58c86e797e225c9 100644 (file)
@@ -202,6 +202,48 @@ class TwitterapiAction extends Action {
                
                return NULL;
        }
+
+       function init_document($type='xml') {
+               switch ($type) {
+                case 'xml':
+                       header('Content-Type: application/xml; charset=utf-8');         
+                       common_start_xml();
+                       break;
+                case 'json':
+                       header('Content-Type: application/json; charset=utf-8');
+                       break;
+                case 'rss':
+                       header("Content-Type: application/rss+xml; charset=utf-8");
+                       $this->init_twitter_rss();
+                       break;
+                case 'atom':
+                       header('Content-Type: application/atom+xml; charset=utf-8');
+                       $this->init_twitter_atom();
+                       break;
+                default:
+                       $this->client_error(_('Unsupported type'));
+                       break;
+               }
+       }
+       
+       function end_document($type='xml') {
+               switch ($type) {
+                case 'xml':
+                       common_end_xml();
+                       break;
+                case 'json':
+                       break;
+                case 'rss':
+                       $this->end_twitter_rss();
+                       break;
+                case 'atom':
+                       $this->end_twitter_rss();
+                       break;
+                default:
+                       $this->client_error(_('Unsupported type'));
+                       break;
+               }
+       }
        
        function init_twitter_rss() {
                common_start_xml();