function __construct($config, $auth = NULL)
 {
     parent::__construct($config, $auth);
     osapiLogger::setLevel(osapiLogger::INFO);
     osapiLogger::setAppender(new osapiFileAppender("data/osapi.log"));
     $host = getConfig($config, 'conext_host', TRUE);
     $key = getConfig($config, 'conext_key', TRUE);
     $secret = getConfig($config, 'conext_secret', TRUE);
     $provider = new osapiProvider("https://{$host}/oauth/request_token", "https://{$host}/oauth/authorize", "https://{$host}/oauth/access_token", "https://{$host}/social/rest", "https://{$host}/social/rpc", 'SURFconext', TRUE, NULL);
     $auth = new osapiOAuth2Legged($key, $secret, $this->auth->getUserId());
     $this->osapi = new osapi($provider, $auth);
 }
/**
 * configures and initializes the osapi object
 *
 * @return osapi object
 */
function initIWIWConnect($consumerKey, $consumerSecret, $iwiwBaseURL = "http://iwiw.hu", $iwiwBaseApiURL = "http://api.iwiw.hu")
{
    // Log
    osapiLogger::setLevel(osapiLogger::INFO);
    osapiLogger::setAppender(new osapiFileAppender("/tmp/logs/osapi.log"));
    // Create an identifier for the local user's session
    session_start();
    $localUserId = session_id();
    //The persistent storage
    $storage = new osapiFileStorage('/tmp/osapistorage');
    //$storage = new osapiMemcacheStorage('127.0.0.1','11211');
    //the iwiw provider
    $provider = new osapiIwiwProvider($iwiwBaseURL, $iwiwBaseApiURL);
    $auth = osapiOAuth3Legged_10a_iwiw::performOAuthLogin($consumerKey, $consumerSecret, $storage, $provider, $localUserId);
    $osapi = new osapi($provider, $auth);
    return $osapi;
}
 private function checkLogFunction($functionToTest, $levelToTest, $yesLevels, $noLevels)
 {
     $appender = new osapiDummyAppender();
     osapiLogger::setAppender($appender);
     $message = "Hello world";
     $logMessages = array("NONE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "ALL");
     $oldLevel = osapiLogger::getLevel();
     foreach ($yesLevels as $currentLevel) {
         $appender->lastLog = "";
         osapiLogger::setLevel($currentLevel);
         osapiLogger::$functionToTest($message);
         $this->assertEquals($appender->lastLog, "[" . $logMessages[$levelToTest] . "][" . date(DATE_RFC822) . "] - {$message}\n");
     }
     foreach ($noLevels as $currentLevel) {
         $appender->lastLog = "";
         osapiLogger::setLevel($currentLevel);
         osapiLogger::$functionToTest($message);
         echo $appender->lastLog;
         $this->assertEquals($appender->lastLog, "");
     }
     osapiLogger::setLevel($oldLevel);
 }
示例#4
0
<?php

// Require the osapi library
require_once "../src/osapi.php";
// Enable logger.
osapiLogger::setLevel(osapiLogger::INFO);
osapiLogger::setAppender(new osapiConsoleAppender());
$consumerKey = 'CONSUMER_KEY';
$consumerSecret = 'CONSUMER_SECRET';
$callbackUrl = 'CALLBACK_URL';
// needed to scope the access token storage
$localUserId = '';
$storage = new osapiFileStorage('/tmp/osapi');
$provider = new osapiVzOAuth2Provider(osapiVzOAuth2Provider::STUDIVZ);
if (isset($_GET['platform']) && $_GET['platform'] === 'schuelervz') {
    $provider = new osapiVzOAuth2Provider(osapiVzOAuth2Provider::SCHUELERVZ);
}
$auth = osapiOAuth2::performOAuthLogin($consumerKey, $consumerSecret, $storage, $provider, $callbackUrl, 'openid', array('gender', 'emails', 'thumbnailUrl'), 'my custom message', 'state', $localUserId);
if ($auth->getAccessToken()->getplatform() === 'schuelervz') {
    $provider = new osapiVzOAuth2Provider(osapiVzOAuth2Provider::SCHUELERVZ);
}
$osapi = new osapi($provider, $auth);
// Start a batch so that many requests may be made at once.
$batch = $osapi->newBatch();
// Fetch the current user.
$self_request_params = array('userId' => '@me', 'groupId' => '@self', 'fields' => array());
$batch->add($osapi->people->get($self_request_params), 'self');
$result = $batch->execute();
var_dump($result);
 *   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 *   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 *   THE SOFTWARE.
 **/
require_once dirname(__FILE__) . '/../common.inc.php';
/**
 * Yahoo! Open Social Rest End Point: http://appstore.apps.yahooapis.com/social/rest
 */
// get current session id
$session_id = session_id();
// enable osapi logging to file
osapiLogger::setLevel(osapiLogger::INFO);
osapiLogger::setAppender(new osapiFileAppender(sys_get_temp_dir() . '/opensocial.log'));
// create yahoo open social provider
$provider = new osapiYahooProvider();
// create file system storage using system temp directory
$storage = new osapiFileStorage(sys_get_temp_dir());
// if this is a YAP application, the access token and secret
// will be provided.
if (isset($_POST['yap_viewer_access_token']) && isset($_POST['yap_viewer_access_token_secret']) && isset($_POST['yap_viewer_guid'])) {
    $oauth = new osapiOAuth3Legged(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, $storage, $provider, $_POST['yap_viewer_guid'], $_POST['yap_viewer_guid'], $_POST['yap_viewer_access_token'], $_POST['yap_viewer_access_token_secret']);
} else {
    $oauth = osapiOAuth3Legged::performOAuthLogin(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, $storage, $provider, $session_id);
}
// create open social instance from yahoo provider + oauth credentials
$opensocial = new osapi($provider, $oauth);
// The number of friends to fetch.
$friend_count = 10;
<?php

/**
 * Copyright 2009 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
// Report everything
ini_set('error_reporting', E_ALL | E_STRICT);
// Use a default timezone or else strtotime will raise errors
date_default_timezone_set('America/Los_Angeles');
// Include paths to the library and test folder
set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__)) . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../src'));
require_once 'osapi.php';
// Enable logger.
osapiLogger::setLevel(osapiLogger::INFO);
osapiLogger::setAppender(new osapiFileAppender("/tmp/logs/osapi.log"));