当前位置: 首页>>代码示例>>PHP>>正文


PHP OAuth::setRequestEngine方法代码示例

本文整理汇总了PHP中OAuth::setRequestEngine方法的典型用法代码示例。如果您正苦于以下问题:PHP OAuth::setRequestEngine方法的具体用法?PHP OAuth::setRequestEngine怎么用?PHP OAuth::setRequestEngine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OAuth的用法示例。


在下文中一共展示了OAuth::setRequestEngine方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($consumer_key, $consumer_secret, $signature_method = OAUTH_SIG_METHOD_HMACSHA1, $auth_type = 0)
 {
     if (!class_exists('OAuth')) {
         return ar_error::raiseError('OAuth PECL extension not installed', ar_exceptions::CONFIGURATION_ERROR);
     }
     $oauth = new OAuth($consumer_key, $consumer_secret, $signature_method, $auth_type);
     $oauth->setRequestEngine(OAUTH_REQENGINE_STREAMS);
     parent::__construct($oauth);
 }
开发者ID:poef,项目名称:ariadne,代码行数:9,代码来源:oauth.php

示例2: twitter_post

function twitter_post($auth, $text, $short_url, $image = false)
{
    global $globals;
    if (empty($auth['twitter_token']) || empty($auth['twitter_token_secret']) || empty($auth['twitter_consumer_key']) || empty($auth['twitter_consumer_secret'])) {
        return false;
    }
    if (!class_exists("OAuth")) {
        syslog(LOG_NOTICE, "Meneame: pecl/oauth is not installed");
        return;
    }
    if (!$auth['twitter_consumer_key'] || !$auth['twitter_consumer_secret'] || !$auth['twitter_token'] || !$auth['twitter_token_secret']) {
        syslog(LOG_NOTICE, "Meneame: consumer_key, consumer_secret, token, or token_secret not defined");
        return;
    }
    $req_url = 'https://api.twitter.com/oauth/request_token';
    $acc_url = 'https://api.twitter.com/oauth/access_token';
    $authurl = 'https://api.twitter.com/oauth/authorize';
    $api_url = 'https://api.twitter.com/1.1/statuses/update.json';
    $api_media_url = 'https://api.twitter.com/1.1/statuses/update_with_media.json';
    $api_args = array("empty_param" => NULL);
    $maxlen = 140 - 24;
    // minus the url length
    if ($image) {
        $maxlen -= 24;
        echo "Adding image: {$image}\n";
        $api_args['@media[]'] = '@' . $image;
        $url = $api_media_url;
    } else {
        $url = $api_url;
    }
    $msg = mb_substr(text_to_summary(html_entity_decode($text), $maxlen), 0, $maxlen);
    $msg_full = $msg . ' ' . $short_url;
    $api_args["status"] = $msg_full;
    $oauth = new OAuth($auth['twitter_consumer_key'], $auth['twitter_consumer_secret'], OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
    $oauth->debug = 1;
    $oauth->setRequestEngine(OAUTH_REQENGINE_CURL);
    // For posting images
    $oauth->setToken($auth['twitter_token'], $auth['twitter_token_secret']);
    try {
        $oauth->fetch($url, $api_args, OAUTH_HTTP_METHOD_POST, array("User-Agent" => "pecl/oauth"));
    } catch (Exception $e) {
        syslog(LOG_INFO, 'Menéame, Twitter caught exception: ' . $e->getMessage() . " in " . basename(__FILE__) . "\n");
        echo "Twitter post failed: {$msg} " . mb_strlen($msg) . "\n";
        return false;
    }
    // $response_info = $oauth->getLastResponseInfo();
    // echo $oauth->getLastResponse() . "\n";
    return true;
}
开发者ID:GallardoAlba,项目名称:Meneame,代码行数:49,代码来源:external_post.php

示例3: makeRequestAndPrintResponse

 private static function makeRequestAndPrintResponse($method, $params, $signature_method = OAUTH_SIG_METHOD_HMACSHA1)
 {
     $oauth = new OAuth(Settings::$USOSAPI_CONSUMER_KEY, Settings::$USOSAPI_CONSUMER_SECRET, $signature_method, OAUTH_AUTH_TYPE_URI);
     if ($signature_method == OAUTH_SIG_METHOD_PLAINTEXT) {
         $oauth->setRequestEngine(OAUTH_REQENGINE_CURL);
     }
     if (Settings::$DEBUG) {
         $oauth->enableDebug();
     }
     $url = Settings::$USOSAPI_BASE_URL . $method;
     try {
         $oauth->fetch($url, $params, OAUTH_HTTP_METHOD_POST);
     } catch (OAuthException $E) {
         /* Ignored on purpose. $response_info will be filled either way. */
     }
     $response_info = $oauth->getLastResponseInfo();
     header("HTTP/1.0 {$response_info["http_code"]}");
     header("Content-Type: {$response_info["content_type"]}");
     print $oauth->getLastResponse();
 }
开发者ID:JulianVolodia,项目名称:jquery-usos,代码行数:20,代码来源:usosapiProxy.php

示例4: GetSignedRequestParameters

 /**
  * @see OAuthHanlder::GetSignedRequestParameters()
  */
 public function GetSignedRequestParameters($credentials, $url, $method = NULL)
 {
     if (empty($method)) {
         $method = 'POST';
     }
     $params = array();
     $params['oauth_consumer_key'] = $credentials['oauth_consumer_key'];
     $params['oauth_token'] = $credentials['oauth_token'];
     $params['oauth_signature_method'] = 'HMAC-SHA1';
     $params['oauth_timestamp'] = time();
     $params['oauth_nonce'] = uniqid();
     $params['oauth_version'] = '1.0a';
     $oauth = new OAuth($credentials['oauth_consumer_key'], $credentials['oauth_consumer_secret'], OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_AUTHORIZATION);
     $oauth->setRequestEngine(OAUTH_REQENGINE_CURL);
     $oauth->setVersion('1.0a');
     $oauth->setToken($credentials['oauth_token'], $credentials['oauth_token_secret']);
     $oauth->setTimestamp($params['oauth_timestamp']);
     $oauth->setNonce($params['oauth_nonce']);
     $oauth->setVersion($params['oauth_version']);
     $signature = $oauth->generateSignature(self::$OAUTH_METHOD_ENUMS[$method], $url);
     $params['oauth_signature'] = $signature;
     return $params;
 }
开发者ID:trancerr,项目名称:apiadlib,代码行数:26,代码来源:PeclOAuthHandler.php

示例5: OAuth

<?php

require 'server.inc';
$x = new OAuth('conskey', 'conssecret', OAUTH_SIG_METHOD_PLAINTEXT);
$x->setRequestEngine(OAUTH_REQENGINE_STREAMS);
$x->setTimestamp(12345);
$x->setNonce('testing');
$port = random_free_port();
$pid = http_server("tcp://127.0.0.1:{$port}", array("HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 40\r\n\r\noauth_token=1234&oauth_token_secret=4567"), $output);
$x->setAuthType(OAUTH_AUTH_TYPE_URI);
$x->setToken("key", "secret");
var_dump($x->getAccessToken("http://127.0.0.1:{$port}/test"));
fseek($output, 0, SEEK_SET);
var_dump(stream_get_contents($output));
http_server_kill($pid);
开发者ID:badlamer,项目名称:hhvm,代码行数:15,代码来源:plaintext2.php

示例6: GetClient

 /**
  * Constructs a new OAuth client object.
  * @param array $credentials the credentials to use
  * @param string $authorizationType the authorization type to use
  * @return OAuth a new OAuth client
  */
 private function GetClient($credentials, $authorizationType = NULL)
 {
     $client = new OAuth($credentials['oauth_consumer_key'], $credentials['oauth_consumer_secret'], OAUTH_SIG_METHOD_HMACSHA1, $authorizationType);
     $client->setRequestEngine(OAUTH_REQENGINE_CURL);
     $client->setVersion('1.0a');
     if (isset($credentials['oauth_token']) && isset($credentials['oauth_token_secret'])) {
         $client->setToken($credentials['oauth_token'], $credentials['oauth_token_secret']);
     }
     // SSL settings.
     if (defined('SSL_VERIFY_PEER') && SSL_VERIFY_PEER) {
         $client->setSSLChecks(OAUTH_SSLCHECK_PEER);
     } else {
         $client->setSSLChecks(OAUTH_SSLCHECK_NONE);
     }
     if (defined('SSL_VERIFY_HOST') && SSL_VERIFY_HOST) {
         if ($client->sslChecks == OAUTH_SSLCHECK_PEER) {
             $client->setSSLChecks(OAUTH_SSLCHECK_BOTH);
         } else {
             $client->setSSLChecks(OAUTH_SSLCHECK_HOST);
         }
     }
     if (defined('SSL_CA_PATH') && SSL_CA_PATH != '') {
         // The second parameter must be explicitly set to NULL due to a bug in
         // version 1.2.2 and earlier. See https://bugs.php.net/bug.php?id=60226
         $client->setCAPath(SSL_CA_PATH, NULL);
     }
     if (defined('SSL_CA_FILE') && SSL_CA_FILE != '') {
         $client->setCAPath(NULL, SSL_CA_FILE);
     }
     return $client;
 }
开发者ID:fertandil87,项目名称:adwords-php-client,代码行数:37,代码来源:PeclOAuthHandler.php

示例7: OAuth

<?php

include "constants.php";
try {
    $oauth = new OAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
    /* Uncomment the line below to get lots of debug */
    $oauth->enableDebug();
    /* multipart only works with the cURL engine at the moment */
    $oauth->setRequestEngine(OAUTH_REQENGINE_CURL);
    $request_token_info = $oauth->getRequestToken(TWITTER_REQUEST_TOKEN_URL);
    printf("I think I got a valid request token, navigate your www client to:\n\n%s?oauth_token=%s\n\nOnce you finish authorizing, hit ENTER or INTERRUPT to exit\n\n", TWITTER_AUTHORIZE_URL, $request_token_info["oauth_token"]);
    $in = fopen("php://stdin", "r");
    fgets($in, 255);
    printf("Grabbing an access token...\n");
    /* grab the access token, which is your persistent token which you use for future requests */
    $oauth->setToken($request_token_info["oauth_token"], $request_token_info["oauth_token_secret"]);
    $access_token_info = $oauth->getAccessToken(TWITTER_ACCESS_TOKEN_URL);
    printf("Access token: %s\n", $access_token_info["oauth_token"]);
    printf("Access token secret: %s\n", $access_token_info["oauth_token_secret"]);
    $oauth->setToken($access_token_info["oauth_token"], $access_token_info["oauth_token_secret"]);
    printf("Sending the background image...\n");
    $oauth->fetch(TWITTER_UPDATE_PROFILE_BG_API, array("tile" => "true", "@image" => "@" . dirname(__FILE__) . "/php.jpg;filename=php.jpg;type=image/jpg"), OAUTH_HTTP_METHOD_POST);
    /* from this point on OAuth is over, now handling the JSON response is in order */
    $res = json_decode($oauth->getLastResponse());
    printf("Twitter background image URL: %s\n", $res->profile_background_image_url);
} catch (OAuthException $E) {
    print_r($E);
}
开发者ID:checkout51,项目名称:pecl-web_services-oauth,代码行数:28,代码来源:updateBackgroundImage.php


注:本文中的OAuth::setRequestEngine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。