weather; $current_conditions = $weather->current_conditions; $forecast_information = $weather->forecast_information; $forecast_date = $forecast_information->forecast_date; $condition = $current_conditions->condition; $temp_f = $current_conditions->temp_f; $temp_c = $current_conditions->temp_c; $humidity = $current_conditions->humidity; $icon = $current_conditions->icon; $wind_condition = $current_conditions->wind_condition; $c = $condition['data']; $tf = $temp_f['data']; $tc = $temp_c['data']; $hum = $humidity['data']; $image = $icon['data']; $wind = $wind_condition['data']; $date = $forecast_date['data']; $post = "Hoy $date : $c con $tc °C, $tf °F $hum $wind "; // Set username and password $username = 'usuario'; $password = 'password'; // The message you want to send $message = $post; // The twitter API address $url = 'http://twitter.com/statuses/update.xml'; // Alternative JSON version // $url = 'http://twitter.com/statuses/update.json'; // Set up and execute the curl process $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, "$url"); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_handle, CURLOPT_POST, 1); curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message"); curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password"); $buffer = curl_exec($curl_handle); curl_close($curl_handle); // check for success or failure if (empty($buffer)) { echo 'message'; } else { echo 'success'; } ?>