我的代码需要帮助,我知道问题出在哪里,但我不知道如何修复它。
我从其他服务中获取统计信息,当此统计信息开启时," - "我会打开我的cron然后我遇到了问题:
ErrorException [注意]:未定义的偏移量:1
代码行是:
<?php
class Model_Datasource_1 extends Model_Datasource implements Model_Datasource_Service {
protected $usernameList = array();
protected $userEarnings = array();
public function getUserEarnings($date, $serviceUsername) {
if (empty($this->userEarnings[$date][$serviceUsername])) {
$this->curl->getContent('hidden link', Curl::POST, array(
'performer' => $serviceUsername,
'stat' => 'Statystyka'
));
$content = $this->curl->getContent('hidden link' . date('Y-m-d', strtotime($date)) . '¶ms[endDate]=' . date('Y-m-d', strtotime($date)));
preg_match('#<span class="payout">([0-9\.]+) USD</span>#si', $content, $matches);
$this->userEarnings[$date][$serviceUsername][] = array(
'statDatetime' => date('Y-m-d ', strtotime($date)) . date('H:i:s'),
'statEarnings' => (float) $matches[1]
);
}
return (!empty($this->userEarnings[$date][$serviceUsername])) ? $this->userEarnings[$date][$serviceUsername] : array();
}
public function getUsernameList() {
if (empty($this->usernameList)) {
$pageNumber = 1;
do {
$content = $this->curl->getContent('hidden link' . $pageNumber . '|1|1&filter=A');
preg_match_all('#<form id="performer_([^"]+)" action="hidden link', $content, $matches);
$this->usernameList = array_merge($this->usernameList, $matches[1]);
$pageNumber++;
} while (count($matches[1]) == 5);
}
return $this->usernameList;
}
public function logIn($userName, $userPassword) {
$this->curl->getContent('hidden link');
$content = $this->curl->getContent('hidden link');
preg_match('#<input type="hidden" name="ref" value="([^"]*)">#Usi', $content, $matches);
$content = $this->curl->getContent('hidden link', Curl::POST, array(
'studio' => $userName,
'password' => $userPassword,
'ref' => $matches[1],
'Submit' => 'Zalogowanie tutaj'
));
}
public function logOut() {
$this->curl = new Curl();
}
}
?>
答案 0 :(得分:1)
你的意思是:
'statEarnings' => floatval($matches[1])