require_once("include/html2plain.php");
require_once("mod/share.php");
require_once("include/Photo.php");
+ require_once("mod/item.php");
+ require_once('include/security.php');
+ require_once('include/contact_selectors.php');
+ require_once('library/HTMLPurifier.auto.php');
+ require_once('include/html2bbcode.php');
+ require_once('mod/wall_upload.php');
+ require_once("mod/proxy.php");
+ require_once("include/message.php");
+
/*
* Twitter-Like API
die('This api requires login');
}
- require_once('include/security.php');
authenticate_success($record); $_SESSION["allow_api"] = true;
call_hooks('logged_in', $a->user);
if (strpos($a->query_string, ".atom")>0) $type="atom";
if (strpos($a->query_string, ".as")>0) $type="as";
+ $stamp = microtime(true);
$r = call_user_func($info['func'], $a, $type);
+ $duration = (float)(microtime(true)-$stamp);
+ logger("API call duration: ".round($duration, 2)."\t".$a->query_string, LOGGER_DEBUG);
+
if ($r===false) return;
switch($type){
$r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1", dbesc(normalise_link($uinfo[0]['url'])));
}
- require_once('include/contact_selectors.php');
$network_name = network_to_name($uinfo[0]['network'], $uinfo[0]['url']);
$ret = Array(
$txt = requestdata('status');
//$txt = urldecode(requestdata('status'));
- require_once('library/HTMLPurifier.auto.php');
- require_once('include/html2bbcode.php');
-
if((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) {
$txt = html2bb_video($txt);
$config = HTMLPurifier_Config::createDefault();
$a->argv[1]=$user_info['screen_name']; //should be set to username?
$_REQUEST['hush']='yeah'; //tell wall_upload function to return img info instead of echo
- require_once('mod/wall_upload.php');
$bebop = wall_upload_post($a);
//now that we have the img url in bbcode we can add it to the status and insert the wall item.
$_REQUEST['body']=$txt."\n\n".$bebop;
- require_once('mod/item.php');
item_post($a);
// this should output the last post (the one we just posted).
// logger('api_post: ' . print_r($_POST,true));
if(requestdata('htmlstatus')) {
- require_once('library/HTMLPurifier.auto.php');
- require_once('include/html2bbcode.php');
-
$txt = requestdata('htmlstatus');
if((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) {
$_REQUEST['title'] = requestdata('title');
$parent = requestdata('in_reply_to_status_id');
+
+ // Twidere sends "-1" if it is no reply ...
+ if ($parent == -1)
+ $parent = "";
+
if(ctype_digit($parent))
$_REQUEST['parent'] = $parent;
else
if(x($_FILES,'media')) {
// upload the image if we have one
$_REQUEST['hush']='yeah'; //tell wall_upload function to return img info instead of echo
- require_once('mod/wall_upload.php');
$media = wall_upload_post($a);
if(strlen($media)>0)
$_REQUEST['body'] .= "\n\n".$media;
// call out normal post function
- require_once('mod/item.php');
item_post($a);
// this should output the last post (the one we just posted).
return false;
}
- require_once('mod/wall_upload.php');
$media = wall_upload_post($a, false);
if(!$media) {
// Output error
if (!x($_REQUEST, "source"))
$_REQUEST["source"] = api_source();
- require_once('mod/item.php');
item_post($a);
}
$ret = api_statuses_show($a, $type);
- require_once('include/items.php');
drop_item($id, false);
return($ret);
$include_entities = strtolower(x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:"false");
if ($include_entities != "true") {
- require_once("mod/proxy.php");
preg_match_all("/\[img](.*?)\[\/img\]/ism", $bbcode, $images);
// If image cache is activated, then use the following sizes:
// thumb (150), small (340), medium (600) and large (1024)
if (!get_config("system", "proxy_disabled")) {
- require_once("mod/proxy.php");
$media_url = proxy_url($url);
$sizes = array();
$sender = api_get_user($a);
- require_once("include/message.php");
-
if ($_POST['screen_name']) {
$r = q("SELECT `id`, `nurl`, `network` FROM `contact` WHERE `uid`=%d AND `nick`='%s'",
intval(api_user()),
function oauth_get_client($request){
-
+
$params = $request->get_parameters();
$token = $params['oauth_token'];
-
- $r = q("SELECT `clients`.*
- FROM `clients`, `tokens`
- WHERE `clients`.`client_id`=`tokens`.`client_id`
+
+ $r = q("SELECT `clients`.*
+ FROM `clients`, `tokens`
+ WHERE `clients`.`client_id`=`tokens`.`client_id`
AND `tokens`.`id`='%s' AND `tokens`.`scope`='request'",
dbesc($token));
if (!count($r))
return null;
-
+
return $r[0];
}
function api_content(&$a) {
if ($a->cmd=='api/oauth/authorize'){
- /*
+ /*
* api/oauth/authorize interact with the user. return a standard page
*/
-
+
$a->page['template'] = "minimal";
-
-
+
+
// get consumer/client from request token
try {
$request = OAuthRequest::from_request();
} catch(Exception $e) {
echo "<pre>"; var_dump($e); killme();
}
-
-
+
+
if (x($_POST,'oauth_yes')){
-
+
$app = oauth_get_client($request);
if (is_null($app)) return "Invalid request. Unknown token.";
$consumer = new OAuthConsumer($app['client_id'], $app['pw'], $app['redirect_uri']);
$verifier = md5($app['secret'].local_user());
set_config("oauth", $verifier, local_user());
-
-
+
+
if ($consumer->callback_url!=null) {
$params = $request->get_parameters();
$glue="?";
goaway($consumer->callback_url.$glue."oauth_token=".OAuthUtil::urlencode_rfc3986($params['oauth_token'])."&oauth_verifier=".OAuthUtil::urlencode_rfc3986($verifier));
killme();
}
-
-
-
+
+
+
$tpl = get_markup_template("oauth_authorize_done.tpl");
$o = replace_macros($tpl, array(
'$title' => t('Authorize application connection'),
'$info' => t('Return to your app and insert this Securty Code:'),
'$code' => $verifier,
));
-
+
return $o;
-
-
+
+
}
-
-
+
+
if(! local_user()) {
//TODO: we need login form to redirect to this page
notice( t('Please login to continue.') . EOL );
return login(false,$request->get_parameters());
}
//FKOAuth1::loginUser(4);
-
+
$app = oauth_get_client($request);
if (is_null($app)) return "Invalid request. Unknown token.";
-
-
-
+
+
+
$tpl = get_markup_template('oauth_authorize.tpl');
$o = replace_macros($tpl, array(
'$title' => t('Authorize application connection'),
'$yes' => t('Yes'),
'$no' => t('No'),
));
-
+
//echo "<pre>"; var_dump($app); killme();
-
+
return $o;
}
echo api_call($a);
killme();
}
-
-
-