2011-11-18 95 views
3

因此,我正在处理一个简单的电子邮件导入脚本,从本网站上的帖子所说的那些帖子来看,那些用于销售的脚本要么是狡猾的,要么是不值得花费的钱,而且据我所知,PHP, JS我认为这是不难的,毕竟我已经与Twitter API和Facebook API合作过。Yahoo联系API

但是我似乎在路上遇到了一个小颠簸。

你看我使用雅虎自己的脚本Yahoo.inc - http://developer.yahoo.com/social/sdk/php/

,一切都进展顺利,成为可能。但是,当我尝试获取联系人时,我似乎无法做到。现在我已经在我的应用程序的API设置中请求联系人的读取请求,所以我不知道这个问题。

这里是我的代码,我使用

$contacts = $user->getContacts(); 

不过就像我失去了一些东西,但不知道它好像不工作的工作:(

它是什么。

可能有人请帮助从正确的方式获得Yahoo提供的getContacts函数的电子邮件。

+0

这是什么运气?这是让我疯了http://stackoverflow.com/questions/30919089/yahoo-php-sdk-getcontacts-intermittently-works – Dan

回答

4

而不是getContacts(),您可以使用yql查询:

$session = YahooSession::requireSession(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID); 
$query = sprintf("select * from social.contacts where guid=me;"); 
$response = $session->query($query); 


/**** printing the contact emails starts ****/ 
if(isset($response)){ 

    foreach($response->query->results->contact as $id){ 

     foreach($id->fields as $subid){ 

       if($subid->type == 'email') 
       echo $subid->value."<br />"; 
     } 
    } 
} 
/**** printing the contact emails ends ****/ 
+0

我会试试这个 - 让你知道 – RussellHarrower

+0

@RussellHarrower:你让它工作? – mithunsatheesh

1

查看github,您可以看到yahoo-yos-php软件包已弃用。它将被替换为yahoo-yos-php5包。也许你应该下载并尝试使用它。

顺便说一句,当yahoo-yos-php5使用YQL查询时,yahoo-yos-php使用YOS API调用(doc)来获取数据。 因此,使用新软件包的最终结果与仅包含在yahoo发行版中的@mithunsatheesh解决方案相同。

这里是一个link到类和函数本身:

public function getContacts($guid = null, $offset = 0, $limit = 10) 
{ 
    if($guid == null && !is_null($this->token)) 
    { 
    $guid = $this->token->yahoo_guid; 
    } 

    $rsp = $this->yql(sprintf('SELECT * FROM social.contacts(%s,%s) WHERE guid="%s"', $offset, $limit, $guid)); 

    return isset($rsp->query->results) ? $rsp->query->results : false; 
} 
0

搜寻此方法getContacts()从雅虎API文件(即Yahoo.inc),并增加限制500最初,它是10.