12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- class OembedproxyAction extends OembedAction
- {
- function handle($args)
- {
-
- GNUsocial::setApi(true);
-
- $token = $this->trimmed('token');
- if (!$token || $token != common_session_token()) {
-
- $this->clientError(_m('There was a problem with your session token. '.
- 'Try again, please.'));
- }
- $format = $this->arg('format');
- if ($format && $format != 'json') {
-
- throw new ClientException(_m('Invalid format; only JSON supported.'));
- }
- $url = $this->arg('url');
- if (!common_valid_http_url($url)) {
-
- throw new ClientException(_m('Invalid URL.'));
- }
- $params = array();
- if ($this->arg('maxwidth')) {
- $params['maxwidth'] = $this->arg('maxwidth');
- }
- if ($this->arg('maxheight')) {
- $params['maxheight'] = $this->arg('maxheight');
- }
- $data = oEmbedHelper::getObject($url, $params);
- $this->init_document('json');
- print json_encode($data);
- }
- }
|