yos-social-php5 icon indicating copy to clipboard operation
yos-social-php5 copied to clipboard

How to fetch private data through YQL?

Open laics1984 opened this issue 12 years ago • 7 comments

How I can fetch private data through YQL with YahooYQLQuery class and execute()? As in the example, it only show fetching public data. The error that I received while fetching data is:

YQL query failed with error: "Authentication Error. The table social.contacts requires a higher security level than is provided, you provided ANY but at least USER is expected".

Thank you.

laics1984 avatar Feb 08 '12 18:02 laics1984

Same problem.

Progi1984 avatar Apr 04 '12 09:04 Progi1984

Are there any methods to debug this error? I'm experiencing the same issue after verifying that I gave myself correct r/w access.

remmons avatar Jul 02 '12 21:07 remmons

Did any of you guys solve this? I'm experiencing the same problem. It works in yahoo's console since i am logged in (i guess), but it doesn't work in my own app, even though i've gone through the Oauth-process.

jakanjakan avatar Feb 02 '14 17:02 jakanjakan

This script fetch data through YQL https://github.com/eugeniotcs/YQLQueryYahooapis/tree/master

Link update on 2016-09-20

Bye

ghost avatar Apr 26 '14 15:04 ghost

Same question... did someone have working example of fetching private data through YQL?

qmegas avatar Sep 20 '16 14:09 qmegas

For example:

<?php
YahooLogger::setDebug(false);
YahooLogger::setDebugDestination('LOG');

if ( empty($_COOKIE['language']) ) $_COOKIE['language'] = 'en';
require '../language/lang-'.$_COOKIE['language'].'.php'; 

if (isset($_GET['usermailfrom'])) $_SESSION['usermailfrom'] = $_GET['usermailfrom']; else $_SESSION['usermailfrom'] = '[email protected]';
$host = 'http://' . $_SERVER["HTTP_HOST"]; 

// check for the existance of a session.
// this will determine if we need to show a pop-up and fetch the auth url,
// or fetch the user's social data.
$hasSession = YahooSession::hasSession($_SESSION['consumer_key'], $_SESSION['consumer_secret'], $_SESSION['app_id']);
if ($hasSession == FALSE) {
  // create the callback url use if you need
  $callback = YahooUtil::current_url();

  // pass the credentials to get an auth url.
  // this URL will be used for the pop-up.
  $auth_url = YahooSession::createAuthorizationUrl($_SESSION['consumer_key'], $_SESSION['consumer_secret'], $callback);
} else {
  header("Location: $host/sites/all/libraries/invite-friends-yahoo/connected.php");
}   

after this you can set session

if (isset($_GET['logout']) && $_GET['logout'] == 1) {
  // if a session exists and the logout flag is detected
  // clear the session tokens and reload the page.
  YahooSession::clearSession();
  unset($_SESSION['access_token']);
  unset($_SESSION['access_token_secret']);
  unset($_SESSION['access_token_consumer']);
  unset($_SESSION['access_token_sessionhandle']);
  unset($_SESSION['oauth_provider']);
  unset($_SESSION['yahoouser']);    
  unset($_SESSION['consumer_key']);
  unset($_SESSION['consumer_secret']);
  unset($_SESSION['app_id']);

  header("Location: $host/sites/all/libraries/invite-friends-yahoo/index.php");
}

See full code in repository @link https://github.com/eugeniotcs/YQLQueryYahooapis/tree/master

ghost avatar Sep 20 '16 19:09 ghost

@Qmegas YQL still uses OAuth 1.0 for authentication, so I think authenticating your request to YQL with OAuth 1.0 token will work. Also, If you're working with social data by any chance, you are better working with Social Directory API (you can use OAuth 2.0 access tokens with it).

salamza avatar Oct 15 '16 19:10 salamza