Skip to content

Instantly share code, notes, and snippets.

@dianaprajescu
Created August 4, 2012 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dianaprajescu/3258852 to your computer and use it in GitHub Desktop.
Save dianaprajescu/3258852 to your computer and use it in GitHub Desktop.
JTwitter test
<?php
// We are a valid Joomla entry point.
define('_JEXEC', 1);
// Setup the base path related constant.
define('JPATH_BASE', dirname(__FILE__));
// Maximise error reporting.
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Bootstrap the application.
require dirname(__FILE__).'/bootstrap.php';
class TwitterApp extends JApplicationWeb
{
/**
* Display the application.
*/
function doExecute(){
$key = "lIio7RcLe5IASG5jpnZrA";
$secret = "dl3BrWij7LT04NUpy37BRJxGXpWgjNvMrneuQ11EveE";
$my_url = JUri::current();
$option = new JRegistry;
$option->set('consumer_key', $key);
$option->set('consumer_secret', $secret);
$option->set('callback', $my_url);
$option->set('sendheaders', true);
$oauth = new JTwitterOAuth($option);
//$access_token = $obj->getStoredToken();
//$oauth->setToken($access_token);
$new_token = $oauth->authenticate();
// Store the new access token.
/*if ($new_token != $access_token)
{
$obj->storeToken($new_token);
}*/
$twitter = new JTwitter($oauth);
$friends = $twitter->friends;
//$response = $friends->getFriendshipsLookup('testuse70078234');
$statuses = $twitter->statuses;
$response = $statuses->tweet('Testing JTwitter code.');
print_r($response);
}
}
$web = JApplicationWeb::getInstance('TwitterApp');
JFactory::$application = $web;
$session = JFactory::getSession();
if($session->isActive() == false){
$session->initialise(JFactory::getApplication()->input);
$session->start();
}
// Run the application
$web->execute();
@rsurjano
Copy link

but you can do a module to test, because i test your code and appear me error 500 :( help me plz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment