コード例 #1
0
ファイル: TestInit.php プロジェクト: sherifgmansour/Twitter
<?php

namespace Twitter\Tests;

error_reporting(E_ALL | E_STRICT);
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/TextUI/TestRunner.php';
require_once __DIR__ . '/../../../lib/Twitter/ClassLoader.php';
$classLoader = new \Twitter\ClassLoader('Twitter');
$classLoader->register();
set_include_path(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lib' . PATH_SEPARATOR . get_include_path());
コード例 #2
0
ファイル: example.php プロジェクト: andreia/Twitter
<?php

require '../lib/Twitter/ClassLoader.php';
if (!isset($_REQUEST['q'])) {
    $_REQUEST['q'] = null;
}
$errors = array();
function prepareTweet($tweet)
{
    $tweet = preg_replace('/@([A-Za-z0-9]+)/', '<a href="http://www.twitter.com/$1">@$1</a>', $tweet);
    return $tweet;
}
$classLoader = new \Twitter\ClassLoader('Twitter');
$classLoader->setIncludePath('../lib');
$classLoader->register();
if ($_POST) {
    $client = new \Twitter\Client\HTTP($_POST['username'], $_POST['password']);
    $account = new \Twitter\Api\Account($client);
    if (!$account->verify()) {
        $errors[] = 'Invalid credentials';
    }
} else {
    $client = new \Twitter\Client\HTTP('apiunittest', 'changeme');
}
if (empty($errors)) {
    if ($_POST) {
        $statuses = new \Twitter\Api\Statuses($client);
        $result = $statuses->updateStatus($_POST['comment'] . ' ' . $_REQUEST['q']);
    }
}
$search = new \Twitter\Api\Search($client);