Esempio n. 1
0
File: app.php Progetto: arfrank/Busk
 function play()
 {
     if ($this->session->userdata('user_id')) {
         //get oauth stuff
     } else {
         redirect('/join');
     }
     $this->load->library('form_validation');
     $this->form_validation->set_rules('name', 'Stage Name', 'required|trim');
     $this->form_validation->set_rules('paypal_email', 'Donation Email Address', 'required|trim');
     $this->form_validation->set_rules('website', 'Website URL', 'required|trim');
     if ($this->form_validation->run() == FALSE) {
         require_once "/Users/aaronfrank/Sites/busk/php/OAuth.php";
         require_once "/Users/aaronfrank/Sites/busk/php/OAuthConfig.php";
         $key = '';
         //'<your app's API key>';
         $secret = '';
         //'<your app's secret>';
         $request_token_endpoint = 'http://api.justin.tv/oauth/request_token';
         $oauth_access_token_endpoint = 'http://api.justin.tv/oauth/access_token';
         $authorize_endpoint = 'http://api.justin.tv/oauth/authorize';
         $test_consumer = new OAuthConsumer($key, $secret, NULL);
         //prepare to get request token
         $sig_method = new OAuthSignatureMethod_HMAC_SHA1();
         $parsed = parse_url($request_token_endpoint);
         $req_req = OAuthRequest::from_consumer_and_token($test_consumer, NULL, "GET", $request_token_endpoint);
         $req_req->sign_request($sig_method, $test_consumer, NULL);
         $req_token = doHttpRequest($req_req->to_url());
         //assuming the req token fetch was a success, we should have
         //oauth_token and oauth_token_secret
         parse_str($req_token, $tokens);
         $oauth_token = $tokens['oauth_token'];
         $oauth_token_secret = $tokens['oauth_token_secret'];
         $consumer = $test_consumer;
         // new OAuthConsumer($oauth_token, $oauth_token_secret, NULL);
         $auth_token = new OAuthConsumer($oauth_token, $oauth_token_secret);
         $access_token_req = new OAuthRequest("GET", $oauth_access_token_endpoint);
         $access_token_req = $access_token_req->from_consumer_and_token($test_consumer, $auth_token, "GET", $oauth_access_token_endpoint);
         $access_token_req->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, $auth_token);
         $after_access_request = doHttpRequest($access_token_req->to_url());
         $access_tokens = $tokens;
         $access_token = new OAuthConsumer($access_tokens['oauth_token'], $access_tokens['oauth_token_secret']);
         $streamkey_req = $access_token_req->from_consumer_and_token($consumer, $access_token, "GET", "http://api.justin.tv/api/stream/new_stream_key/busktv.xml");
         $streamkey_req->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, $access_token);
         $xml = doHttpRequest($streamkey_req->to_url());
         $xml_parser = xml_parser_create();
         xml_parse_into_struct($xml_parser, $xml, $vals, $index);
         $data['stream_key'] = $vals[0]['value'];
         $view_name = 'play_form';
     } else {
         $data['stream_key'] = $this->input->post('stream_key');
         $view_name = 'play';
     }
     $data['title'] = "Broadcast";
     $this->load->view($view_name, $data);
 }
Esempio n. 2
0
function get_VkMethod($method_name, $parameters = array())
{
    ksort($parameters);
    $parameters = params($parameters);
    $url = VKAPI_SERVER . $method_name . "?" . $parameters;
    $result = doHttpRequest($url);
    $result = urldecode($result);
    $data = json_decode($result, true);
    return $data["response"];
}
Esempio n. 3
0
                $auth_token, "GET", $oauth_access_token_endpoint);

$access_token_req->sign_request(new OAuthSignatureMethod_HMAC_SHA1(),$consumer,
                $auth_token);

$after_access_request = doHttpRequest($access_token_req->to_url());
parse_str($after_access_request,$access_tokens);

$access_token = new OAuthConsumer($access_tokens['oauth_token'], $access_tokens['oauth_token_secret']);

$streamkey_req = $access_token_req->from_consumer_and_token($consumer,
                $access_token); 

$streamkey_req->sign_request(new OAuthSignatureMethod_HMAC_SHA1(),$consumer,$access_token);

$after_request = doHttpRequest($streamkey_req->to_url());

//Get streamkey from returned XML
$stream_key = parseStream_KeyFromXML ($after_request);

if ($stream_key == '')
    echo ("Error getting stream_key from API!");
else
{   //We got the key! Embed the broadcaster and we're done.
    echo "SUCCEEESSS";
}

//helper function to get the stream_key from returned XML
function parseStream_KeyFromXML($xml)
{
    $xml_parser = xml_parser_create();
Esempio n. 4
0
/**
 * returns the complete HTML for the query interface without the Wiki toolbars etc.
 * so that the QI can be embedded into another application such as the FCK editor or
 * the Excel Client.
 * Within the parameter string the options noPreview and noLayout can be set (value
 * is not required). If the parameter is set, in the html the div for the result
 * preview of the current query is not show, and/or the layout manager is not
 * displayed.
 * 
 * @param  string key=value pairs urlencoded i.e. noPreview%26noLayout
 * @return string $html
 */
function smwf_qi_getPage($args = "")
{
    global $wgServer, $wgScript, $wgLang;
    $qiScript = $wgScript . '/' . $wgLang->getNsText(NS_SPECIAL) . ':QueryInterface';
    // fetch the Query Interface by calling the URL http://host/wiki/index.php/Special:QueryInterface
    // save the source code of the above URL in $page
    $page = "";
    if (function_exists('curl_init')) {
        list($httpErr, $page) = doHttpRequestWithCurl($wgServer, $qiScript);
    } else {
        if (strtolower(substr($wgServer, 0, 5)) == "https") {
            return "Error: for HTTPS connections please activate the Curl module in your PHP configuration";
        }
        list($httpErr, $page) = doHttpRequest($wgServer, $_SERVER['SERVER_PORT'], $qiScript);
    }
    // this happens at any error (also if the URL can be called but a 404 is returned)
    if ($page === false || $httpErr != 200) {
        return "Error: SMWHalo seems not to be installed. Please install the SMWHalo extension to be able to use the Query Interface.<br/>HTTP Error code " . $httpErr;
    }
    // create the new source code, by removing the wiki stuff,
    // keep the header (because of all css and javascripts) and the main content part only
    $newPage = "";
    mvDataFromPage($page, $newPage, '<body');
    $newPage .= '<body style="background-image:none; background-color: #ffffff;"><div id="globalWrapper"><div id="content">';
    mvDataFromPage($page, $newPage, "<!-- start content -->", false);
    mvDataFromPage($page, $newPage, "<!-- end content -->");
    $newPage .= "</div></div></body></html>";
    // remove the Switch to Semantic Notification button, incase it's there
    $newPage = preg_replace('/<button id="qi-insert-notification-btn"([^>]*)>(.*?)<\\/button>/m', '', $newPage);
    // have a string where to store JS command for onload event
    $onloadArgs = '';
    // parse submited params
    $params = array();
    parse_str($args, $params);
    // when called from the Excel Bridge, params noPreview and noLayout must be set
    // also the "Copy to clipboard" button must be hidden. The Excel Bridge is recognized by the
    // appropriate Useragent, params may not be set but will adjusted automatically
    if (isset($_SERVER['HTTP_USER_AGENT']) && stripos($_SERVER['HTTP_USER_AGENT'], 'Excel Bridge') !== false) {
        $params['noPreview'] = true;
        $params['noLayout'] = true;
        $newPage = str_replace('onclick="qihelper.copyToClipboard()"', 'onclick="qihelper.copyToClipboard()" style="display: none;"', $newPage);
        $onloadArgs .= 'initialize_qi_from_excelbridge(); ';
    } else {
        $excelBridge = '';
    }
    // check params and change HTML of the Query Interface
    if (isset($params['noPreview'])) {
        $newPage = str_replace('<div id="previewlayout">', '<div id="previewlayout" style="display: none;">', $newPage);
    }
    if (isset($params['noLayout'])) {
        $newPage = str_replace('<div id="querylayout">', '<div id="querylayout" style="display: none;">', $newPage);
    }
    if (isset($params['query'])) {
        $queryString = str_replace('"', '&quot;', $params['query']);
        $queryString = str_replace("'", "\\'", $queryString);
        $onloadArgs .= 'initialize_qi_from_querystring(\'' . $queryString . '\');';
    }
    if (strlen($onloadArgs) > 0) {
        $newPage = str_replace('<body', '<body onload="' . $onloadArgs . '"', $newPage);
    }
    // remove unnecessary scripts
    $newPage = preg_replace_callback('/<script[^>]+>([^<]+|<!)*<\\/script>/', 'smwf_qi_deleteScriptsCallback', $newPage);
    return $newPage;
}
Esempio n. 5
0
$meetcha_home_destination = 'http://localhost/meetcha/';
// <<URL pointing to Meetcha App Home>> can be '../' if php is under meetcha app dir
$_SESSION['destination'] = $_REQUEST['destination'] ? $_REQUEST['destination'] : $meetcha_home_destination;
$scriptName = str_replace('index.php', '', $_SERVER['SCRIPT_NAME']);
$app_home_url = 'http://' . $_SERVER['HTTP_HOST'] . $scriptName;
// Meetcha
$base_url = $php_home_url;
// "http://localhost/oAuthtest2/";
$request_token_endpoint = 'https://api.meetup.com/oauth/request/';
$authorize_endpoint = 'http://www.meetup.com/authorize/?oauth_token=request_token_key';
$test_consumer = new OAuthConsumer($key, $secret, NULL);
//prepare to get request token
$sig_method = new OAuthSignatureMethod_HMAC_SHA1();
$parsed = parse_url($request_token_endpoint);
$params = array(callback => $base_url);
parse_str($parsed['query'], $params);
$req_req = OAuthRequest::from_consumer_and_token($test_consumer, NULL, "GET", $request_token_endpoint, $params);
// Meetcha
$req_req->set_parameter("oauth_callback", $app_home_url . 'isvalid.php');
// 'http://localhost/oAuthtest2/isvalid.php');
$req_req->sign_request($sig_method, $test_consumer, NULL);
$req_token = doHttpRequest($req_req->to_url());
//assuming the req token fetch was a success, we should have
//oauth_token and oauth_token_secret
parse_str($req_token, $tokens);
$oauth_token = $tokens['oauth_token'];
$oauth_token_secret = $tokens['oauth_token_secret'];
$_SESSION['tmp_tokens'] = $tokens;
$auth_url = "http://www.meetup.com/authorize/?oauth_token=" . $oauth_token;
//Forward us to meetup for auth
Header("Location: {$auth_url}");