Changeset 513401
- Timestamp:
- 03/02/2012 09:52:39 AM (14 years ago)
- File:
-
- 1 edited
-
ti-stat/tags/0.4/ti_stat.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ti-stat/tags/0.4/ti_stat.php
r512953 r513401 215 215 216 216 <?php 217 218 217 219 if ($auth->counter_id!= '') 218 220 { 219 221 220 222 echo 'debug'.$auth->counter_id; 221 223 222 224 } else { 223 225 echo 'debug_false'; 224 226 $counters = ti_counters($auth->token); 225 227 … … 921 923 $newoptions['exp_time']= 0; 922 924 $newoptions['promote'] = $_POST['promote']; 925 $newoptions['data'] = $options['data']; 923 926 } 924 927 … … 1508 1511 } 1509 1512 1513 function ti_counters($token) 1514 { 1515 $xml = new SimpleXMLElement(ti_Y_API('http://api-metrika.yandex.ru/counters?oauth_token='.$token,'GET')); 1516 1517 $counters = $xml->counters; 1518 $count = (int)$counters->attributes()->count; 1519 1520 for ($i=0;$i<$count;$i++) 1521 { 1522 1523 $data[$i]['url']=(string) $counters->counter[$i]->site; 1524 $data[$i]['permission']=(string) $counters->counter[$i]->permission; 1525 $data[$i]['name']=(string) $counters->counter[$i]->name; 1526 $data[$i]['id']=(string) $counters->counter[$i]->id; 1527 } 1528 1529 return $data; 1530 } 1531 1532 1533 function ti_Y_API($url,$method) 1534 { 1535 1536 $ch = curl_init(); 1537 curl_setopt($ch, CURLOPT_URL, $url); 1538 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 1539 curl_setopt($ch, CURLOPT_HTTPHEADER, array($url, $method)); 1540 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 1541 $return = curl_exec($ch); 1542 1543 1544 if(curl_errno($ch)) 1545 { 1546 return false; 1547 echo 'Curl errno'; 1548 } 1549 1550 $http_code = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE); 1551 1552 if ($http_code != 200) 1553 { 1554 echo $http_code; 1555 return false; 1556 } 1557 else 1558 { 1559 return $return; 1560 1561 } 1562 } 1563 1564 1565 1566 1510 1567 ?>
Note: See TracChangeset
for help on using the changeset viewer.