<?php

/*
Copyright (c) 2009 Yahoo! Inc. All rights reserved.
The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license
*/
require_once "config.php";
require_once "php_sdk/Yahoo.inc";
require_once "CustomSessionStore.inc";
//capture POST data for update
$title = $_POST['title'];
$description = $_POST['description'];
$link = $_POST['link'];
$token = $_POST['token'];
//initialize session
$sessionStore = new CustomSessionStore();
$session = YahooSession::initSession(KEY, SECRET, APPID, TRUE, CALLBACK, $sessionStore);
$yahoo_user = $session->getSessionedUser();
//create new update
if ($title) {
    $suid = $yahoo_user->guid . time();
    if ($yahoo_user->insertUpdate($suid, $title, $link, $description)) {
        echo "Update Successful";
    }
}
Пример #2
0
<?php

require 'config.inc';
require_once "yosdk/Yahoo.inc";
require_once "CustomSessionStore.inc";
$applicationId = '';
$redirect = TRUE;
$callback = '';
$guid = '{guid}';
//app logic would provide this
$sessionStore = new CustomSessionStore($guid);
$session = YahooSession::initSession(KEY, SECRET, $applicationId, $redirect, $callback, $sessionStore);
$user = $session->getSessionedUser();
$start = 0;
$count = 10;
$total = 10;
var_dump($user->getConnections($start, $count, $total));
Пример #3
0
    /**
     * Requires that there be a session in this PHP page request. Generates
     * a redirect for the user to log in, if necessary. You must call
     * requireSession() before any data is sent back to the user in order
     * for the redirect to work.
     *
     * @param $consumerKey The OAuth consumer key.
     * @param $consumerSecret The OAuth consumer key secret.
     * @param $applicationId The application ID, optional.
     * @param $callback The callback URL to redirect the user to after
     *                  they verify the application access. If no callback
     *                  is provided, the current page URL will be used.
     * @param $sessionStore The session store implementation to use. See
     *                      YahooSessionStore for more information. If no
     *                      session store is provided, clearSession will
     *                      instantiate a NativeSessionStore and use that.
     * @param $verifier The oauth_verifier returned by the OAuth servers
     *                  after authorization. Passing NULL indicates that
     *                  authorization was completed previously or that
     *                  requireSession() should look for oauth_verifier in
     *                  the $_GET superglobal.
     * @return YahooSession The current session or NULL if a session cannot
     *                      be established.
     */
    function requireSession($consumerKey, $consumerSecret, $applicationId = NULL,
                          $callback = NULL, $sessionStore = NULL, $verifier = NULL)
    {
        if(is_null($sessionStore)) {
            $sessionStore = new NativeSessionStore();
        }

        if(is_null($verifier) && array_key_exists("oauth_verifier", $_GET)) {
            $verifier = $_GET["oauth_verifier"];
        }

        return YahooSession::initSession($consumerKey, $consumerSecret, $applicationId, TRUE, $callback, $sessionStore, $verifier);
    }
Пример #4
0
<?php

require_once "../../yosdk/Yahoo.inc";
require_once "CustomSessionStore.inc";
require_once "config.inc";
$redirect = TRUE;
$guid = '{guid}';
//set by app logic
$sessionStore = new CustomSessionStore($guid);
$session = YahooSession::initSession(KEY, SECRET, APPID, $redirect, CALLBACK, $sessionStore);
?>
<pre>
<?php 
print_r($session->accessToken);
?>
</pre>
Пример #5
0
<?php

require 'config.inc';
require YOSDK_PATH;
$session_store = new CookieSessionStore();
$session = YahooSession::initSession(KEY, SECRET, APP_ID, TRUE, BASE_URL . '/callback.php', $session_store);
$access_token_readable = print_r($session->accessToken, true);
//send an update
$user = $session->getSessionedUser();
$suid = 'update' . time();
//just a unique string
$title = 'this is an update';
$link = 'http://developer.yahoo.com/social/updates/';
$user->insertUpdate($suid, $title, $link);
//create a link to the logged-in user's profile page
$profile_url = 'http://profiles.yahoo.com/u/' . $user->guid;
?>
<head>
	<link rel="stylesheet" type="text/css" href="style.css">
</head>
<h1>Success!</h1>
You have now authorized updates originating from this site to be published on Yahoo!
<p/>
An event notification has been sent to Yahoo! to demonstrate this behavior.  You can see it on <a href="<?php 
echo $profile_url;
?>
" target="_blank">your Yahoo! profile page</a>.
<p/>
In case you're interested, this is the access token this site can store, refresh, and use to sign requests to the Updates API:
<pre>
<?php