/** * Initializes Yahoo API * * @package Social Deals Engine * @since 1.0.0 */ public function wps_deals_initialize_yahoo() { //check yahoo is enable,consumer key not empty,consumer secrets not empty and app id should not empty if (isset($_GET['openid_mode']) && $_GET['openid_mode'] == 'id_res' && isset($_GET['wpsocialdeals']) && $_GET['wpsocialdeals'] == 'yahoo') { //load yahoo class $yahoo = $this->wps_deals_social_load_yahoo(); //check yahoo class is loaded or not if (!$yahoo) { return false; } $request_token = new YahooOAuthRequestToken($_GET['openid_oauth_request_token'], ''); // exchange request token for access token $this->yahoo->token = $this->yahoo->getAccessToken($request_token); // store access token for later use $yahoo_access_token = $this->yahoo->token->to_string(); //check yahoo oauth access token is set or not if (!empty($yahoo_access_token)) { // if session is still present ( not expired),then restore access token from session $this->yahoo->token = YahooOAuthAccessToken::from_string($yahoo_access_token); $user_data = $this->yahoo->getProfile(); if (isset($user_data->profile) && !empty($user_data->profile)) { //set user data to session $this->session->set('wps_deals_yahoo_user_cache', $user_data->profile); } } } }
public function fetch_access_token($oauth_request) { $http = YahooCurl::fetch($oauth_request->to_url(), array(), array(), $oauth_request->get_normalized_http_method()); return YahooOAuthAccessToken::from_string($http['response_body']); }
case 'cancel': unset($_SESSION['yahoo_oauth_access_token']); unset($_REQUEST['openid_mode']); header('Location: ' . $oauthapp->callback_url); exit; // openid cancelled break; case 'associate': // openid associate user break; default: } } else { if (isset($_SESSION['yahoo_oauth_access_token'])) { // restore access token from session $oauthapp->token = YahooOAuthAccessToken::from_string($_SESSION['yahoo_oauth_access_token']); // do something with user data if (isset($_POST['action'])) { switch ($_POST['action']) { case 'updateStatus': if (isset($_POST['status']) && !empty($_POST['status'])) { $status = strip_tags($_POST['status']); $oauthapp->setStatus(null, $status); } header('Location: ' . $oauthapp->callback_url); exit; break; case 'postUpdate': if (isset($_POST['update']) && !empty($_POST['update'])) { $update = strip_tags($_POST['update']); $oauthapp->insertUpdate(null, $update, $update, $oauthapp->callback_url);
$errors = FALSE; $response = array("status" => "FAILURE", "statusMessage" => "POST_YAHOO_UPDATE_SERVICE_FAILED"); $yahoo_token = isset($_REQUEST["yahoo_token"]) ? $_REQUEST["yahoo_token"] : FALSE; $title = isset($_REQUEST["title"]) ? $_REQUEST["title"] : ""; $description = isset($_REQUEST["description"]) ? $_REQUEST["description"] : ""; $link = isset($_REQUEST["link"]) ? $_REQUEST["link"] : ""; $return = isset($_REQUEST["return"]) ? strtolower($_REQUEST["return"]) : "json"; if (empty($yahoo_token)) { $errors = TRUE; $response["statusMessage"] = "MISSING_PARAMETER_YAHOO_TOKEN"; } if (!($return === "json" || $return === "xml" || $return === "php")) { $errors = TRUE; $response["statusMessage"] = "INVALID_RETURN_TYPE"; $return = "json"; } $oauthapp = new YahooOAuthApplication(YAHOO_OAUTH_CONSUMER_KEY, YAHOO_OAUTH_CONSUMER_SECRET, YAHOO_OAUTH_APP_ID, YAHOO_OAUTH_DOMAIN); // restore access token from session $oauthapp->token = YahooOAuthAccessToken::from_string($yahoo_token); $suid = md5($title . $description . $link . time()); $retval = $oauthapp->insertUpdate(null, $description, $title, $link); if ($retval) { $response["data"] = $retval; $response["status"] = "SUCCESS"; $response["statusMessage"] = "SUCCESS"; } // Generate properly encoded return data if ('xml' === $return) { header("Content-Type: text/xml"); } echo formatOutputArray($response, $return);