I need help in my code, exactly i know where is the problem, but i dont know how to fix it.
I'm catching a stats from oter service, and when this stats are on "-" and i will turn on my cron then i got an problem from :
ErrorException [ Notice ]: Undefined offset: 1
The codeline is:
<?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();
}
}
?>
你的意思是:
'statEarnings' => floatval($matches[1])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.