Install and configure PtwiX


Requirements

Ptwix, for working with full options, requires curl installed on your server and the curl module for PHP, working whith the PHP5 version or latest. If you have a domain in hosting probably the curl is already installed.


Install

Extract content of ptwix archive after download and copy the entire folder wherever you want on your webserver.
This is the tree structure of the ptwix foder:
Folder
Make sure that the cache folder has the writing permissions beceause in this folder ptwix writes the xml file for cache requests.
If you want, you can move the cache folder out of ptwix direcotry and put it in other place on your webserver.


Configuration

The first step is to go in the as folder open the PtwiX_reader.php and edit these lines

$username="yourtwitterusername";
$password="yourtwitterpassword";
$url_path="http://www.mysite.com/ptwix/";
$cache_folder="/var/www/examplesite/ptwix/cache/";

When you have correctly set this file you are ready for the first running. To create a PtwiX instance you must include the ptwix core and call the constructor.
The ptwix constructor accepts in this order the following parameters:

Instance Name: The name of this instance of ptwix, the names of ptwix instace must be unique in the page
Username: Your twitter account username
Password: Your twitter account password
Url path: The url path of ptwix folder (http://www.mysite.com/ptwix/)
Cache folder path: The absolute path of cache folder
Timeline type: (Optional) The timeline to show (user timeline or friends timeline) default friends timeline
Theme: (Optional) The name of theme folder, default gray-blue


This is a first example.

<? include "core/PtwiX.php";

$PtwiX=new PtwiX('second','user','pass','http://www.mysite.com/ptwix/','/var/www/ptwix/cache/',PtwiX::$FRIENDS_TIMELINE,'silver-red');
?>
<html>
<head>
<? $PtwiX->printCssRef(); ?>
</head>
<body>
<? $PtwiX->printBox(); ?>
</body>
</html>


The default ptwix dimension is 400x300 but with setDimension method you can change it.
printBox is the method that prints ptwix in your page.
If you have problems to positionate printCssRef method in head tag you can include the stylesheet of your desidered theme manually.
This is a example with personal dimension and manually stylesheet include.

<? include "core/PtwiX.php";

$PtwiX=new PtwiX('second','user','pass','http://www.mysite.com/ptwix/','/var/www/ptwix/cache/',PtwiX::$FRIENDS_TIMELINE,'silver-red');
$PtwiX->setDimension(400,300);
?>
<html>
<head>
<link href="ptwix/themes/silver-blue/PtwiX.css" rel="stylesheet" type="text/css" />
</head>
<body>
<? $PtwiX->printBox(); ?>
</body>
</html>


Disable curl

For disable the curl request mode you can setting to false the useCurl property in this way

$myptwixInstance->useCurl(false);

Remember that with curl disabled ptwix can show only the user timeline. You also disable curl in as/PtwiX_reader.php file.

Twitter search

For use ptwix for show search results read this article