Its small class for twitter /** * Twitter API abstract class * @package twitterlibphp */ abstract class TwitterBase {
/** * the last HTTP status code returned * @access private * @var integer */ private $http_status; /** * the whole URL of the last API call * @access private * @var string */ private $last_api_call; /** * the application calling the API * @access private * @var string */ private $application_source; function updateImg($options = array(), $format = 'json') { $options = array('image' => $image, 'type' => $type); return $this->apiCall('account/update_profile_image', 'post', $format, $options); } } /** * Access to the Twitter API through HTTP auth * @package twitterlibphp */ class Twitter extends TwitterBase { /** * the Twitter credentials in HTTP format, username:password * @access private * @var string */ var $credentials; /** * Fills in the credentials {...@link $credentials} and the application source {...@link $application_source}. * @param string $username Twitter username * @param string $password Twitter password * @param $source string Optional. Name of the application using the API */ function __construct($username, $password, $source = null) { $this->credentials = sprintf("%s:%s", $username, $password); $this->application_source = $source; } /** * Executes an API call * @param string $twitter_method The Twitter method to call * @param string $http_method The HTTP method to use * @param string $format Return format * @param array $options Options to pass to the Twitter method * @param boolean $require_credentials Whether or not credentials are required * @return string */ protected function apiCall($twitter_method, $http_method, $format, $options, $require_credentials = true) { $curl_handle = curl_init(); $api_url = sprintf('http://twitter.com/%s.%s', $twitter_method, $format); if (($http_method == 'get') && (count($options) > 0)) { $api_url .= '?' . http_build_query($options); } //echo $api_url . "\n"; curl_setopt($curl_handle, CURLOPT_URL, $api_url); if ($require_credentials) { curl_setopt($curl_handle, CURLOPT_USERPWD, $this->credentials); } if ($http_method == 'post') { curl_setopt($curl_handle, CURLOPT_POST, true); curl_setopt($curl_handle, CURLOPT_POSTFIELDS, http_build_query($options)); } curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array('Expect:')); $twitter_data = curl_exec($curl_handle); $this->http_status = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE); $this->last_api_call = $api_url; curl_close($curl_handle); return $twitter_data; } } And little function if (isset($_POST['save_download'])) { $upload_file = $_FILES['twimg']['name']; $upload_dir = 'up/'; $tmp_path = $_FILES['twimg']['tmp_name']; $full_path_copy = $upload_dir.$upload_file; $img = $_SERVER['DOCUMENT_ROOT']."/t/$full_path_copy"; $type = $_FILES['twimg']['type']; if (move_uploaded_file($tmp_path,$full_path_copy)) { $twitter = new Twitter("login", "password"); $options = array('image' => $img, 'type' => $type); $twitter->updateImg($options); } } But it is dont work(((( Where my wrong? ps: sorry for my bad english