我有两个关于wp\\u remote\\u get的函数。
我想将所有数据(函数输出)写入txt文件?如何操作?
the functions;
// facebook
function hayransayisi(){
$fb_id = \'206938902665808\';
$count = get_transient(\'fan_count\');
if ($count !== false) return $count;
$count = 0;
$data = wp_remote_get(\'http://api.facebook.com/restserver.php?method=facebook.fql.query&query=SELECT%20fan_count%20FROM%20page%20WHERE%20page_id=\'.$fb_id.\'\');
if (is_wp_error($data)) {
return \'yok öylesi!!!\';
}else{
$count = strip_tags($data[body]);
}
set_transient(\'fan_count\', $count, 60*60*24); // 24 hour cache
return $count;
}
推特功能;
// Twitter
function rarst_twitter_user( $username, $field, $display = false ) {
$interval = 3600;
$cache = get_option(\'rarst_twitter_user\');
$url = \'http://api.twitter.com/1/users/show.json?screen_name=\'.urlencode($username);
if ( false == $cache )
$cache = array();
if ( !isset( $cache[$username][$field] ) ) {
$cache[$username][$field] = NULL;
$cache[$username][\'lastcheck\'] = 0;
}
if( $cache[$username][\'lastcheck\'] < (time()-$interval) ) {
static $memorycache;
if ( isset($memorycache[$username]) ) {
$data = $memorycache[$username];
}
else {
$result = wp_remote_retrieve_body(wp_remote_request($url));
$data = json_decode( $result );
if ( is_object($data) )
$memorycache[$username] = $data;
}
if ( is_object($data) ) {
foreach ($cache[$username] as $key => $value)
if( isset($data->$key) )
$cache[$username][$key] = $data->$key;
$cache[$username][\'lastcheck\'] = time();
}
else {
$cache[$username][\'lastcheck\'] = time()+60;
}
update_option( \'rarst_twitter_user\', $cache );
}
if ( false != $display )
echo $cache[$username][$field];
return $cache[$username][$field];
}
有人帮忙吗?谢谢