Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add examples to README + tweaked examples for notices

  • Loading branch information...
commit 0cea94b737ec9f0703b765135d9e6fda379c3b4f 1 parent 2bce49e
@dustinwhittle dustinwhittle authored
Showing with 43 additions and 18 deletions.
  1. +24 −3 README.markdown
  2. +12 −9 sample/delicious.php
  3. +7 −6 sample/sampleapp.php
View
27 README.markdown
@@ -134,18 +134,39 @@ application and then you will be redirected back to your application.
In the yosdk/sample directory you'll find delicious.php, a sample yahoo open
application that shows how to use YQL to make web service request.
+Make sure to update the OAuth credentials in each bundled example:
+
+ define('OAUTH_CONSUMER_KEY', '###');
+ define('OAUTH_CONSUMER_SECRET', '###');
+ define('OAUTH_DOMAIN', '###');
+ define('OAUTH_APP_ID', '###');
+
+
## Fetching YQL:
- $user = YahooSession::requireSession($consumerKey, $consumerKeySecret, $applicationId)->getSessionedUser();
+ $session = YahooSession::requireSession(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID);
+ $user = $session->getSessionedUser();
- var_dump($user->query('select * from social.connections where owner_guid=me'));
+ var_dump($session->query('select * from social.connections where owner_guid=me'));
## Fetching Social Data:
- $user = YahooSession::requireSession($consumerKey, $consumerKeySecret, $applicationId)->getSessionedUser();
+ $session = YahooSession::requireSession(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID);
+ $user = $session->getSessionedUser();
var_dump($user->getProfile());
+ var_dump($user->getContacts());
+
+
+## Setting YAP Small View:
+
+ $session = YahooSession::requireSession(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID);
+ $user = $session->getSessionedUser();
+
+ $content = '<h1><yml:name> customized small view</h1>';
+ var_dump($user->setSmallView($content));
+
Tests
View
21 sample/delicious.php
@@ -25,28 +25,31 @@
// https://developer.yahoo.com/dashboard/createKey.html
// create a Yahoo! Open Application - http://developer.yahoo.com/dashboard
-$consumerKey = 'dj0yJmk9WUxPUkhFUWxISWpvJmQ9WVdrOWFYWmhTVzVDTXpBbWNHbzlNVGt4TmpJNU1EazROdy0tJnM9Y29uc3VtZXJzZWNyZXQmeD01Ng--';
-$consumerKeySecret = 'f893cf549be5cb37f83b1414e2ff212df2ea4c18';
-$applicationId = 'ivaInB30';
-// oauth dance if not authenticated
-$session = YahooSession::requireSession($consumerKey, $consumerKeySecret, $applicationId);
+define('OAUTH_CONSUMER_KEY', '###');
+define('OAUTH_CONSUMER_SECRET', '###');
+define('OAUTH_DOMAIN', '###');
+define('OAUTH_APP_ID', '###');
+
-// get oauthed user guid + profile
-$user = $session->getSessionedUser();
+// oauth dance if not authenticated
+$session = YahooSession::requireSession(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID);
$header = '<h2><img src="http://delicious.com/favicon.ico" title="Delicious" width="16" height="16" />Delicious // social bookmarking</h2>';
$content
= '<div id="bookmarks">';
// if user is logged in and oauth is valid
-if(is_object($user))
+if(is_object($session))
{
+ // get oauthed user guid + profile
+ $user = $session->getSessionedUser();
+
// load y! profile data
$profile = $user->getProfile();
// get yap app instance for yql / small view
- $application = new YahooApplication($consumerKey, $consumerKeySecret);
+ $application = new YahooApplication(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);
// delicious yql
$yql = "use 'http://www.javarants.com/delicious/delicious.feeds.xml' as delicious.feeds;";
View
13 sample/sampleapp.php
@@ -17,9 +17,10 @@
// Make sure you obtain application keys before continuing by visiting:
// https://developer.yahoo.com/dashboard/createKey.html
-define("CONSUMER_KEY", "dj0yJmk9WUxPUkhFUWxISWpvJmQ9WVdrOWFYWmhTVzVDTXpBbWNHbzlNVGt4TmpJNU1EazROdy0tJnM9Y29uc3VtZXJzZWNyZXQmeD01Ng--");
-define("CONSUMER_SECRET", "f893cf549be5cb37f83b1414e2ff212df2ea4c18");
-define("APP_ID", "ivaInB30");
+define('OAUTH_CONSUMER_KEY', '###');
+define('OAUTH_CONSUMER_SECRET', '###');
+define('OAUTH_DOMAIN', '###');
+define('OAUTH_APP_ID', '###');
if(array_key_exists("logout", $_GET)) {
// if a session exists and the logout flag is detected
@@ -31,7 +32,7 @@
// 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(CONSUMER_KEY, CONSUMER_SECRET, APP_ID);
+$hasSession = YahooSession::hasSession(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID);
if($hasSession == FALSE) {
// create the callback url,
@@ -39,11 +40,11 @@
// pass the credentials to get an auth url.
// this URL will be used for the pop-up.
- $auth_url = YahooSession::createAuthorizationUrl(CONSUMER_KEY, CONSUMER_SECRET, $callback);
+ $auth_url = YahooSession::createAuthorizationUrl(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, $callback);
}
else {
// pass the credentials to initiate a session
- $session = YahooSession::requireSession(CONSUMER_KEY, CONSUMER_SECRET, APP_ID);
+ $session = YahooSession::requireSession(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID);
// if the in_popup flag is detected,
// the pop-up has loaded the callback_url and we can close this window.

0 comments on commit 0cea94b

Please sign in to comment.
Something went wrong with that request. Please try again.