-
Notifications
You must be signed in to change notification settings - Fork 1
/
yahoo.php
107 lines (98 loc) · 2.22 KB
/
yahoo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
Yahoo plugin for the PHP Fat-Free Framework
The contents of this file are subject to the terms of the GNU General
Public License Version 3.0. You may not use this file except in
compliance with the license. Any of the license terms and conditions
can be waived if you get permission from the copyright holder.
Copyright (c) 2009-2012 F3::Factory
Bong Cosca <[email protected]>
@package Yahoo
@version 2.0.12
**/
//! API wrapper for Yahoo! Web services
class Yahoo extends Base {
/**
Notify Yahoo! of changes to Web page by submitting the sitemap
location or Web page URL
@return boolean
@param $url string
@public
**/
static function ping($url) {
$result=simplexml_load_string(
Web::http(
'GET http://search.yahooapis.com/'.
'SiteExplorerService/V1/ping',
http_build_query(array('sitemap'=>$url))
)
);
if ($result->getName()!='Success') {
trigger_error($result['Message']);
return FALSE;
}
return TRUE;
}
/**
Retrieve info about inbound links to a particular page
@return mixed
@param $appid string
@param $path string
@param $count int
@param $start int
@param $omit string
@public
**/
static function inlinks($appid,$path,$count=100,$start=1,$omit='') {
$result=simplexml_load_string(
Web::http(
'GET http://search.yahooapis.com/'.
'SiteExplorerService/V1/inlinkData',
http_build_query(
array(
'appid'=>$appid,
'query'=>$path,
'results'=>$count,
'start'=>$start,
'omit_inlinks'=>$omit,
'output'=>'xml'
)
)
)
);
if ($result->getName()!='ResultSet') {
trigger_error($result['Message']);
return FALSE;
}
$out=array();
foreach ($result->attributes() as $key=>$val)
$out[$key]=(int)$val;
foreach ($result->Result as $item) {
$out['Result'][]=
array(
'title'=>(string)$item->Title,
'url'=>(string)$item->Url
);
}
return $out;
}
/**
Return online status of a Yahoo! ID
@return boolean
@param $id string
@public
**/
static function online($id) {
$result=Web::http(
'GET http://opi.yahoo.com/online',
http_build_query(
array(
'u'=>$id,
'm'=>'a',
't'=>1
)
)
);
return (boolean)(int)$result;
}
}