function wp_ozh_yourls_tweet_it($username, $password, $message) { $ozh_yourls = get_option('ozh_yourls'); if ($ozh_yourls['other'] == 'rply' && isset($ozh_yourls['twitter_api']) && !empty($ozh_yourls['twitter_api'])) { $api_url = $ozh_yourls['twitter_api']; $body = array('status' => $message, 'username' => $ozh_yourls['rply_login'], 'password' => $ozh_yourls['rply_password']); $headers = array(); } else { $api_url = 'http://twitter.com/statuses/update.json'; $body = array('status' => $message); $headers = array('Authorization' => 'Basic ' . base64_encode("{$username}:{$password}")); } $result = wp_ozh_yourls_fetch_url($api_url, 'POST', $body, $headers); // Basic check for success or failure: if body contains <error>some string</error>, not good return preg_match_all('!<error>[^<]+</error>!', $result, $matches) !== 1; }
function wp_ozh_yourls_remote_json($url) { $input = wp_ozh_yourls_fetch_url($url); if (!class_exists('Services_JSON')) { require_once dirname(__FILE__) . '/pear_json.php'; } $json = new Services_JSON(); $obj = $json->decode($input); return $obj; // TODO: some error handling ? }