oEmbed provider does not use the twitter api library classes any more
This commit is contained in:
parent
4f751563c7
commit
7eda7295e4
@ -103,18 +103,18 @@ class AttachmentAction extends Action
|
|||||||
$this->element('link',array('rel'=>'alternate',
|
$this->element('link',array('rel'=>'alternate',
|
||||||
'type'=>'application/json+oembed',
|
'type'=>'application/json+oembed',
|
||||||
'href'=>common_local_url(
|
'href'=>common_local_url(
|
||||||
'api',
|
'oembed',
|
||||||
array('apiaction'=>'oembed','method'=>'oembed.json'),
|
array(),
|
||||||
array('url'=>
|
array('format'=>'json', 'url'=>
|
||||||
common_local_url('attachment',
|
common_local_url('attachment',
|
||||||
array('attachment' => $this->attachment->id)))),
|
array('attachment' => $this->attachment->id)))),
|
||||||
'title'=>'oEmbed'),null);
|
'title'=>'oEmbed'),null);
|
||||||
$this->element('link',array('rel'=>'alternate',
|
$this->element('link',array('rel'=>'alternate',
|
||||||
'type'=>'text/xml+oembed',
|
'type'=>'text/xml+oembed',
|
||||||
'href'=>common_local_url(
|
'href'=>common_local_url(
|
||||||
'api',
|
'oembed',
|
||||||
array('apiaction'=>'oembed','method'=>'oembed.xml'),
|
array(),
|
||||||
array('url'=>
|
array('format'=>'xml','url'=>
|
||||||
common_local_url('attachment',
|
common_local_url('attachment',
|
||||||
array('attachment' => $this->attachment->id)))),
|
array('attachment' => $this->attachment->id)))),
|
||||||
'title'=>'oEmbed'),null);
|
'title'=>'oEmbed'),null);
|
||||||
|
@ -31,8 +31,6 @@ if (!defined('LACONICA')) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once INSTALLDIR.'/lib/twitterapi.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Oembed provider implementation
|
* Oembed provider implementation
|
||||||
*
|
*
|
||||||
@ -46,17 +44,13 @@ require_once INSTALLDIR.'/lib/twitterapi.php';
|
|||||||
* @link http://laconi.ca/
|
* @link http://laconi.ca/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TwitapioembedAction extends TwitterapiAction
|
class OembedAction extends Action
|
||||||
{
|
{
|
||||||
|
|
||||||
function oembed($args, $apidata)
|
function handle($args)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
|
||||||
|
|
||||||
common_debug("in oembed api action");
|
common_debug("in oembed api action");
|
||||||
|
|
||||||
$this->auth_user = $apidata['user'];
|
|
||||||
|
|
||||||
$url = $args['url'];
|
$url = $args['url'];
|
||||||
if( substr(strtolower($url),0,strlen(common_root_url())) == strtolower(common_root_url()) ){
|
if( substr(strtolower($url),0,strlen(common_root_url())) == strtolower(common_root_url()) ){
|
||||||
$path = substr($url,strlen(common_root_url()));
|
$path = substr($url,strlen(common_root_url()));
|
||||||
@ -131,8 +125,7 @@ class TwitapioembedAction extends TwitterapiAction
|
|||||||
default:
|
default:
|
||||||
$this->serverError(_("$path not supported for oembed requests"), 501);
|
$this->serverError(_("$path not supported for oembed requests"), 501);
|
||||||
}
|
}
|
||||||
|
switch($args['format']){
|
||||||
switch($apidata['content-type']){
|
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->init_document('xml');
|
$this->init_document('xml');
|
||||||
$this->elementStart('oembed');
|
$this->elementStart('oembed');
|
||||||
@ -151,12 +144,11 @@ class TwitapioembedAction extends TwitterapiAction
|
|||||||
if($oembed['thumbnail_url']) $this->element('thumbnail_url',null,$oembed['thumbnail_url']);
|
if($oembed['thumbnail_url']) $this->element('thumbnail_url',null,$oembed['thumbnail_url']);
|
||||||
if($oembed['thumbnail_width']) $this->element('thumbnail_width',null,$oembed['thumbnail_width']);
|
if($oembed['thumbnail_width']) $this->element('thumbnail_width',null,$oembed['thumbnail_width']);
|
||||||
if($oembed['thumbnail_height']) $this->element('thumbnail_height',null,$oembed['thumbnail_height']);
|
if($oembed['thumbnail_height']) $this->element('thumbnail_height',null,$oembed['thumbnail_height']);
|
||||||
|
|
||||||
|
|
||||||
$this->elementEnd('oembed');
|
$this->elementEnd('oembed');
|
||||||
$this->end_document('xml');
|
$this->end_document('xml');
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json': case '':
|
||||||
$this->init_document('json');
|
$this->init_document('json');
|
||||||
print(json_encode($oembed));
|
print(json_encode($oembed));
|
||||||
$this->end_document('json');
|
$this->end_document('json');
|
||||||
@ -164,10 +156,51 @@ class TwitapioembedAction extends TwitterapiAction
|
|||||||
default:
|
default:
|
||||||
$this->serverError(_('content type ' . $apidata['content-type'] . ' not supported'), 501);
|
$this->serverError(_('content type ' . $apidata['content-type'] . ' not supported'), 501);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
$this->serverError(_('Only ' . common_root_url() . ' urls over plain http please'), 404);
|
$this->serverError(_('Only ' . common_root_url() . ' urls over plain http please'), 404);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
function init_document($type)
|
||||||
|
{
|
||||||
|
switch ($type) {
|
||||||
|
case 'xml':
|
||||||
|
header('Content-Type: application/xml; charset=utf-8');
|
||||||
|
$this->startXML();
|
||||||
|
break;
|
||||||
|
case 'json':
|
||||||
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
|
|
||||||
|
// Check for JSONP callback
|
||||||
|
$callback = $this->arg('callback');
|
||||||
|
if ($callback) {
|
||||||
|
print $callback . '(';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->serverError(_('Not a supported data format.'), 501);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function end_document($type='xml')
|
||||||
|
{
|
||||||
|
switch ($type) {
|
||||||
|
case 'xml':
|
||||||
|
$this->endXML();
|
||||||
|
break;
|
||||||
|
case 'json':
|
||||||
|
// Check for JSONP callback
|
||||||
|
$callback = $this->arg('callback');
|
||||||
|
if ($callback) {
|
||||||
|
print ')';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->serverError(_('Not a supported data format.'), 501);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -278,16 +278,16 @@ class ShownoticeAction extends OwnerDesignAction
|
|||||||
$this->element('link',array('rel'=>'alternate',
|
$this->element('link',array('rel'=>'alternate',
|
||||||
'type'=>'application/json+oembed',
|
'type'=>'application/json+oembed',
|
||||||
'href'=>common_local_url(
|
'href'=>common_local_url(
|
||||||
'api',
|
'oembed',
|
||||||
array('apiaction'=>'oembed','method'=>'oembed.json'),
|
array(),
|
||||||
array('url'=>$this->notice->uri)),
|
array('format'=>'json','url'=>$this->notice->uri)),
|
||||||
'title'=>'oEmbed'),null);
|
'title'=>'oEmbed'),null);
|
||||||
$this->element('link',array('rel'=>'alternate',
|
$this->element('link',array('rel'=>'alternate',
|
||||||
'type'=>'text/xml+oembed',
|
'type'=>'text/xml+oembed',
|
||||||
'href'=>common_local_url(
|
'href'=>common_local_url(
|
||||||
'api',
|
'oembed',
|
||||||
array('apiaction'=>'oembed','method'=>'oembed.xml'),
|
array(),
|
||||||
array('url'=>$this->notice->uri)),
|
array('format'=>'xml','url'=>$this->notice->uri)),
|
||||||
'title'=>'oEmbed'),null);
|
'title'=>'oEmbed'),null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,15 +117,8 @@ class Router
|
|||||||
|
|
||||||
$m->connect('main/tagother/:id', array('action' => 'tagother'));
|
$m->connect('main/tagother/:id', array('action' => 'tagother'));
|
||||||
|
|
||||||
$m->connect('main/oembed.xml',
|
$m->connect('main/oembed',
|
||||||
array('action' => 'api',
|
array('action' => 'oembed'));
|
||||||
'method' => 'oembed.xml',
|
|
||||||
'apiaction' => 'oembed'));
|
|
||||||
|
|
||||||
$m->connect('main/oembed.json',
|
|
||||||
array('action' => 'api',
|
|
||||||
'method' => 'oembed.json',
|
|
||||||
'apiaction' => 'oembed'));
|
|
||||||
|
|
||||||
// these take a code
|
// these take a code
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user