admin管理员组文章数量:1410674
I am working on a simple email importer script. From what posts on this site have said, the ones that are for sale are either dodgy, or not worth the money spent, and as I know PHP and JS I thought this can't be hard, after all I have worked with Twitter API, and Facebook API.
However I seem to ran into a little bump in the road.
You see I am using Yahoo's very own script Yahoo.inc - /
And all is going well as possible. However when I try to get the contacts I seem not to be able to. Now I have in the API settings for my app, ask for read request for contacts so I know it not that issue.
Here is my code I am using
$contacts = $user->getContacts();
However it seems not work work, it's like I am missing something. What is the correct way to get emails from the getContacts function Yahoo offers?
I am working on a simple email importer script. From what posts on this site have said, the ones that are for sale are either dodgy, or not worth the money spent, and as I know PHP and JS I thought this can't be hard, after all I have worked with Twitter API, and Facebook API.
However I seem to ran into a little bump in the road.
You see I am using Yahoo's very own script Yahoo.inc - http://developer.yahoo./social/sdk/php/
And all is going well as possible. However when I try to get the contacts I seem not to be able to. Now I have in the API settings for my app, ask for read request for contacts so I know it not that issue.
Here is my code I am using
$contacts = $user->getContacts();
However it seems not work work, it's like I am missing something. What is the correct way to get emails from the getContacts function Yahoo offers?
Share Improve this question edited Aug 21, 2018 at 21:03 halfer 20.4k19 gold badges109 silver badges202 bronze badges asked Nov 18, 2011 at 0:29 RussellHarrowerRussellHarrower 6,84025 gold badges113 silver badges225 bronze badges 1- Any luck with this? It's driving me insane stackoverflow./questions/30919089/… – Dan Commented Jun 18, 2015 at 16:07
3 Answers
Reset to default 4instead of the getContacts(), you can use a yql query for that:
$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 ****/
Looking at github you can see that the yahoo-yos-php package is deprecated. it will be replaced by the yahoo-yos-php5 package. Perhaps you should download that and try using it instead.
BTW, yahoo-yos-php uses a YOS API call (doc) to fetch the data while yahoo-yos-php5 uses YQL queries. So the end result of using the new package is the same as @mithunsatheesh solution only packaged in a yahoo distribution.
Here is a link to the class, and the function itself:
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;
}
Search this method getContacts()
from yahoo api file (i.e Yahoo.inc), and increase the limit to 500. Initially it would be 10.
本文标签: phpYahoo Contact APIStack Overflow
版权声明:本文标题:php - Yahoo Contact API - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744957255a2634431.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论