curlh = curl_init(); $request = 'http://login.userapi.com/auth?site=2&login=force&pass='.urlencode($password).'&email='.urlencode($login); curl_setopt($this->curlh, CURLOPT_URL,$request); curl_setopt($this->curlh, CURLOPT_FAILONERROR, true); curl_setopt($this->curlh, CURLOPT_FOLLOWLOCATION, false); // no redirects curl_setopt($this->curlh, CURLOPT_RETURNTRANSFER, true); curl_setopt($this->curlh, CURLOPT_POST, false); curl_setopt($this->curlh, CURLOPT_HEADER, true); $auth_result = curl_exec($this->curlh); if (preg_match("/remixmid=(\d+)/", $auth_result, $matches)) $this->uid = $matches[1]; // get user id from http headers if (preg_match("/.*;sid=(\w*)/", $auth_result, $matches)) $this->sid = $matches[1]; // get session id from http headers } public function call ($func,$params) { curl_setopt($this->curlh, CURLOPT_HEADER, false); $request = 'http://userapi.com/data?act='.$func.'&'.http_build_query ($params).'&sid='.$this->sid; curl_setopt($this->curlh, CURLOPT_URL,$request); $result = curl_exec($this->curlh); return json_decode($result); } public function __destruct () { $request = 'http://login.userapi.com/auth?​login=logout&site=2&​sid='.$this->sid; curl_setopt($this->curlh, CURLOPT_URL,$request); curl_exec($this->curlh); curl_close ($this->curlh); } } // get twitter last status $rss = simplexml_load_file('http://twitter.com/statuses/user_timeline/'.TWITTER_USERNAME.'.rss'); foreach ($rss->channel->item as $status) { if (strpos($status->title,'@')) continue; // filter twitter @username replies $last_status_twitter = str_replace (TWITTER_USERNAME.': ','',$status->title); break; } // get vkontakte last status $vkontakte = new vkuserapi (VKONTAKTE_LOGIN,VKONTAKTE_PASSWORD); $status = $vkontakte->call ('activity',array('id'=>$vkontakte->uid,'from'=>0,'to'=>1)); $last_status_vkontakte = str_replace (PREPEND_WORD,'',$status->d[0][5]); // if last twitt != last vkontakte status - update vkontakte if ($last_status_vkontakte != $last_status_twitter.'.') $vkontakte->call ('set_activity',array('ts'=>time(),'text'=>PREPEND_WORD.$last_status_twitter)); else echo ('no update needed'); unset ($vkontakte); //logout