]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch '0.8.x' of git@gitorious.org:laconica/mainline into 0.8.x
authorEvan Prodromou <evan@controlyourself.ca>
Sun, 2 Aug 2009 14:35:03 +0000 (10:35 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Sun, 2 Aug 2009 14:35:03 +0000 (10:35 -0400)
actions/api.php
actions/twitapigroups.php
lib/twitterapi.php

index 8b92889f8a265c8e7340b956fa363cb0194455ea..99ab262ad77685cdad2a347264e29b079a27382f 100644 (file)
@@ -130,6 +130,7 @@ class ApiAction extends Action
                                 'laconica/wadl',
                                 'tags/timeline',
                                 'oembed/oembed',
+                                'groups/show',
                                 'groups/timeline');
 
         static $bareauth = array('statuses/user_timeline',
index 71a0776f465320d63587e460e163c1390964572b..f899bc36986590614a8bb91ed04b6fb08a9f428d 100644 (file)
@@ -51,6 +51,32 @@ require_once INSTALLDIR.'/lib/twitterapi.php';
  class TwitapigroupsAction extends TwitterapiAction
  {
 
+     function show($args, $apidata)
+     {
+         parent::handle($args);
+
+         common_debug("in groups api action");
+
+         $this->auth_user = $apidata['user'];
+         $group = $this->get_group($apidata['api_arg'], $apidata);
+
+         if (empty($group)) {
+             $this->clientError('Not Found', 404, $apidata['content-type']);
+             return;
+         }
+
+         switch($apidata['content-type']) {
+          case 'xml':
+             $this->show_single_xml_group($group);
+             break;
+          case 'json':
+             $this->show_single_json_group($group);
+             break;
+          default:
+             $this->clientError(_('API method not found!'), $code = 404);
+         }
+     }
+
      function timeline($args, $apidata)
      {
          parent::handle($args);
index b2602e77ca996418b87e628df83281b08c6a2e44..e6af33e8289fe78de0f7d07b236712a12248a269 100644 (file)
@@ -213,6 +213,26 @@ class TwitterapiAction extends Action
         return $twitter_status;
     }
 
+    function twitter_group_array($group)
+    {
+        $twitter_group=array();
+        $twitter_group['id']=$group->id;
+        $twitter_group['url']=$group->permalink();
+        $twitter_group['nickname']=$group->nickname;
+        $twitter_group['fullname']=$group->fullname;
+        $twitter_group['homepage_url']=$group->homepage_url;
+        $twitter_group['original_logo']=$group->original_logo;
+        $twitter_group['homepage_logo']=$group->homepage_logo;
+        $twitter_group['stream_logo']=$group->stream_logo;
+        $twitter_group['mini_logo']=$group->mini_logo;
+        $twitter_group['homepage']=$group->homepage;
+        $twitter_group['description']=$group->description;
+        $twitter_group['location']=$group->location;
+        $twitter_group['created']=$this->date_twitter($group->created);
+        $twitter_group['modified']=$this->date_twitter($group->modified);
+        return $twitter_group;
+    }
+
     function twitter_rss_entry_array($notice)
     {
         $profile = $notice->getProfile();
@@ -413,6 +433,15 @@ class TwitterapiAction extends Action
         $this->elementEnd('status');
     }
 
+    function show_twitter_xml_group($twitter_group)
+    {
+        $this->elementStart('group');
+        foreach($twitter_group as $element => $value) {
+            $this->element($element, null, $value);
+        }
+        $this->elementEnd('group');
+    }
+
     function show_twitter_xml_user($twitter_user, $role='user')
     {
         $this->elementStart($role);
@@ -639,6 +668,22 @@ class TwitterapiAction extends Action
         $this->end_document('json');
     }
 
+    function show_single_json_group($group)
+    {
+        $this->init_document('json');
+        $twitter_group = $this->twitter_group_array($group);
+        $this->show_json_objects($twitter_group);
+        $this->end_document('json');
+    }
+
+    function show_single_xml_group($group)
+    {
+        $this->init_document('xml');
+        $twitter_group = $this->twitter_group_array($group);
+        $this->show_twitter_xml_group($twitter_group);
+        $this->end_document('xml');
+    }
+
     // Anyone know what date format this is?
     // Twitter's dates look like this: "Mon Jul 14 23:52:38 +0000 2008" -- Zach
     function date_twitter($dt)