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


PHP tmhOAuth::url方法代码示例

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


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

示例1: login

 /**
  * Login to facebook and get the associated cloudrexx user.
  */
 public function login()
 {
     // fixing timestamp issue with twitter
     // it is necessary that the twitter server has the same time as our system
     date_default_timezone_set('UTC');
     $tmhOAuth = new \tmhOAuth(array('consumer_key' => $this->applicationData[0], 'consumer_secret' => $this->applicationData[1]));
     // set the timestamp
     $tmhOAuth->config['force_timestamp'] = true;
     $tmhOAuth->config['timestamp'] = time();
     if (isset($_GET['oauth_verifier'])) {
         $tmhOAuth->config['user_token'] = $_SESSION['oauth']['oauth_token'];
         $tmhOAuth->config['user_secret'] = $_SESSION['oauth']['oauth_token_secret'];
         $tmhOAuth->request('POST', $tmhOAuth->url('oauth/access_token', ''), array('oauth_verifier' => $_GET['oauth_verifier'], 'x_auth_access_type' => 'read'));
         $access_token = $tmhOAuth->extract_params($tmhOAuth->response['response']);
         $tmhOAuth->config['user_token'] = $access_token['oauth_token'];
         $tmhOAuth->config['user_secret'] = $access_token['oauth_token_secret'];
         $tmhOAuth->request('GET', $tmhOAuth->url('1.1/account/verify_credentials'));
         $resp = json_decode($tmhOAuth->response['response']);
         unset($_SESSION['oauth']);
         $name = explode(' ', $resp->name);
         self::$userdata = array('first_name' => $name[0], 'last_name' => $name[1], 'email' => $resp->screen_name . '@twitter.com');
         $this->getContrexxUser($resp->id);
     } else {
         $tmhOAuth->request('POST', $tmhOAuth->url('oauth/request_token', ""), array('oauth_callback' => \Cx\Lib\SocialLogin::getLoginUrl(self::OAUTH_PROVIDER)));
         $_SESSION['oauth'] = $tmhOAuth->extract_params($tmhOAuth->response['response']);
         $url = 'https://api.twitter.com/oauth/authenticate?oauth_token=' . $_SESSION['oauth']['oauth_token'];
         \Cx\Core\Csrf\Controller\Csrf::header("Location: " . $url);
         exit;
     }
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:33,代码来源:Twitter.class.php

示例2: nextend_api_auth_flow

function nextend_api_auth_flow()
{
    $api_key = NextendRequest::getVar('api_key');
    $api_secret = NextendRequest::getVar('api_secret');
    $redirect_uri = NextendRequest::getVar('redirect_uri');
    if (session_id() == "") {
        @session_start();
    }
    if (!$api_key || !$api_secret || !$redirect_uri) {
        $api_key = isset($_SESSION['api_key']) ? $_SESSION['api_key'] : null;
        $api_secret = isset($_SESSION['api_secret']) ? $_SESSION['api_secret'] : null;
        $redirect_uri = isset($_SESSION['redirect_uri']) ? $_SESSION['redirect_uri'] : null;
    } else {
        $_SESSION['api_key'] = $api_key;
        $_SESSION['api_secret'] = $api_secret;
        $_SESSION['redirect_uri'] = $redirect_uri;
    }
    if ($api_key && $api_secret) {
        require_once dirname(__FILE__) . "/api/tmhOAuth.php";
        $tmhOAuth = new tmhOAuth(array('consumer_key' => $api_key, 'consumer_secret' => $api_secret));
        if (isset($_REQUEST['oauth_verifier'])) {
            $tmhOAuth->config['user_token'] = $_SESSION['t_oauth']['oauth_token'];
            $tmhOAuth->config['user_secret'] = $_SESSION['t_oauth']['oauth_token_secret'];
            $code = $tmhOAuth->request('POST', $tmhOAuth->url('oauth/access_token', ''), array('oauth_verifier' => $_REQUEST['oauth_verifier']));
            if ($code == 200) {
                $access_token = $tmhOAuth->extract_params($tmhOAuth->response['response']);
                unset($_SESSION['api_key']);
                unset($_SESSION['api_secret']);
                unset($_SESSION['redirect_uri']);
                unset($_SESSION['t_oauth']);
                echo '<script type="text/javascript">';
                echo 'window.opener.setToken("' . $access_token['oauth_token'] . '", "' . $access_token['oauth_token_secret'] . '");';
                echo '</script>';
            } else {
                echo '<h3>Error</h3><br />';
                echo $tmhOAuth->response['response'];
                exit;
            }
        } else {
            $code = $tmhOAuth->request('POST', $tmhOAuth->url('oauth/request_token', ''), array('oauth_callback' => $redirect_uri));
            if ($code == 200) {
                $oauth = $tmhOAuth->extract_params($tmhOAuth->response['response']);
                $_SESSION['t_oauth'] = $oauth;
                $authurl = $tmhOAuth->url("oauth/authenticate", '') . "?oauth_token=" . $oauth['oauth_token'] . "&force_login=1";
                header('Location: ' . $authurl);
                exit;
            } else {
                echo '<h3>Error</h3><br />';
                echo $tmhOAuth->response['response'];
                exit;
            }
        }
    }
}
开发者ID:macconsultinggroup,项目名称:WordPress,代码行数:54,代码来源:auth.php

示例3: sendToSocialMedia

 /**
  *
  * @param array $data
  * @param array $services
  */
 public function sendToSocialMedia(array $data, array $services = array('facebook', 'twitter'))
 {
     // init output
     $ids = array('facebook' => null, 'twitter' => null);
     // Facebook
     if (in_array('facebook', $services) && $this->confirmFacebookAccess()) {
         $facebook = new Facebook(array('appId' => static::$conf->FacebookAppId, 'secret' => static::$conf->FacebookAppSecret));
         $facebook->setAccessToken(static::$conf->FacebookPageAccessToken);
         try {
             $post_id = $facebook->api("/" . static::$conf->FacebookPageId . "/feed", "post", $data);
             $ids['facebook'] = $post_id['id'];
         } catch (FacebookApiException $e) {
             SS_Log::log('Error ' . $e->getCode() . ' : ' . $e->getFile() . ' Line ' . $e->getLine() . ' : ' . $e->getMessage() . "\n" . 'BackTrace: ' . "\n" . $e->getTraceAsString(), SS_Log::ERR);
         }
     }
     // Twitter
     if (in_array('twitter', $services) && $this->confirmTwitterAccess()) {
         $connection = new tmhOAuth(array('consumer_key' => static::$conf->TwitterConsumerKey, 'consumer_secret' => static::$conf->TwitterConsumerSecret, 'user_token' => static::$conf->TwitterOAuthToken, 'user_secret' => static::$conf->TwitterOAuthSecret));
         $tweet = $data['name'] . ": " . $data['link'];
         $code = $connection->request('POST', $connection->url('1.1/statuses/update'), array('status' => $tweet));
         if ($code == 200) {
             $data = json_decode($connection->response['response']);
             $ids['twitter'] = $data->id_str;
         }
     }
     return $ids;
 }
开发者ID:helpfulrobot,项目名称:azt3k-abc-silverstripe-social,代码行数:32,代码来源:PostToSocialMedia.php

示例4: execute

 public function execute()
 {
     $app = Application::instance();
     $cacheDriver = $app->getCacheDriver();
     $twitterOAuthConf = Config::$a['oauth']['providers']['twitter'];
     $tmhOAuth = new \tmhOAuth(array('consumer_key' => $twitterOAuthConf['clientId'], 'consumer_secret' => $twitterOAuthConf['clientSecret'], 'token' => $twitterOAuthConf['token'], 'secret' => $twitterOAuthConf['secret'], 'curl_connecttimeout' => Config::$a['curl']['connecttimeout'], 'curl_timeout' => Config::$a['curl']['timeout'], 'curl_ssl_verifypeer' => Config::$a['curl']['verifypeer']));
     /** @noinspection PhpVoidFunctionResultUsedInspection */
     $code = $tmhOAuth->user_request(array('url' => $tmhOAuth->url('1.1/statuses/user_timeline.json'), 'params' => array('screen_name' => Config::$a['twitter']['user'], 'count' => 3, 'trim_user' => true)));
     if ($code == 200) {
         $result = json_decode($tmhOAuth->response['response'], true);
         $tweets = array();
         foreach ($result as $tweet) {
             $html = $tweet['text'];
             if (isset($tweet['entities']['user_mentions'])) {
                 foreach ($tweet['entities']['user_mentions'] as $ment) {
                     $l = '<a href="http://twitter.com/' . $ment['screen_name'] . '">' . $ment['name'] . '</a>';
                     $html = str_replace('@' . $ment['screen_name'], $l, $html);
                 }
             }
             if (isset($tweet['entities']) && isset($tweet['entities']['urls'])) {
                 foreach ($tweet['entities']['urls'] as $url) {
                     $l = '<a href="' . $url['url'] . '" rev="' . $url['expanded_url'] . '">' . $url['display_url'] . '</a>';
                     $html = str_replace($url['url'], $l, $html);
                 }
             }
             $tweet['user']['screen_name'] = Config::$a['twitter']['user'];
             $tweet['html'] = $html;
             $tweets[] = $tweet;
         }
         $cacheDriver->save('twitter', $tweets);
     }
 }
开发者ID:TonyWoo,项目名称:website,代码行数:32,代码来源:TwitterFeed.php

示例5: LatestTweetsList

 public function LatestTweetsList($limit = '5')
 {
     $conf = SiteConfig::current_site_config();
     if (empty($conf->TwitterName) || empty($conf->TwitterConsumerKey) || empty($conf->TwitterConsumerSecret) || empty($conf->TwitterAccessToken) || empty($conf->TwitterAccessTokenSecret)) {
         return new ArrayList();
     }
     $cache = SS_Cache::factory('LatestTweets_cache');
     if (!($results = unserialize($cache->load(__FUNCTION__)))) {
         $results = new ArrayList();
         require_once dirname(__FILE__) . '/tmhOAuth/tmhOAuth.php';
         require_once dirname(__FILE__) . '/tmhOAuth/tmhUtilities.php';
         $tmhOAuth = new tmhOAuth(array('consumer_key' => $conf->TwitterConsumerKey, 'consumer_secret' => $conf->TwitterConsumerSecret, 'user_token' => $conf->TwitterAccessToken, 'user_secret' => $conf->TwitterAccessTokenSecret, 'curl_ssl_verifypeer' => false));
         $code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline'), array('screen_name' => $conf->TwitterName, 'count' => $limit));
         $tweets = $tmhOAuth->response['response'];
         $json = new JSONDataFormatter();
         if (($arr = $json->convertStringToArray($tweets)) && is_array($arr) && isset($arr[0]['text'])) {
             foreach ($arr as $tweet) {
                 try {
                     $here = new DateTime(SS_Datetime::now()->getValue());
                     $there = new DateTime($tweet['created_at']);
                     $there->setTimezone($here->getTimezone());
                     $date = $there->Format('Y-m-d H:i:s');
                 } catch (Exception $e) {
                     $date = 0;
                 }
                 $results->push(new ArrayData(array('Text' => nl2br(tmhUtilities::entify_with_options($tweet, array('target' => '_blank'))), 'Date' => SS_Datetime::create_field('SS_Datetime', $date))));
             }
         }
         $cache->save(serialize($results), __FUNCTION__);
     }
     return $results;
 }
开发者ID:unisolutions,项目名称:silverstripe-latesttweets,代码行数:32,代码来源:LaTw_Page_Controller_Extension.php

示例6: twitter_profile_page

function twitter_profile_page()
{
    // process form data
    if ($_POST['name']) {
        // post profile update
        $post_data = array("name" => stripslashes($_POST['name']), "url" => stripslashes($_POST['url']), "location" => stripslashes($_POST['location']), "description" => stripslashes($_POST['description']));
        $url = API_NEW . "account/update_profile.json";
        $user = twitter_process($url, $post_data);
        $content = "<h2>Profile Updated</h2>";
    }
    //	http://api.twitter.com/1/account/update_profile_image.format
    if ($_FILES['image']['tmp_name']) {
        require 'tmhOAuth.php';
        list($oauth_token, $oauth_token_secret) = explode('|', $GLOBALS['user']['password']);
        $tmhOAuth = new tmhOAuth(array('consumer_key' => OAUTH_CONSUMER_KEY, 'consumer_secret' => OAUTH_CONSUMER_SECRET, 'user_token' => $oauth_token, 'user_secret' => $oauth_token_secret));
        // note the type and filename are set here as well
        $params = array('image' => "@{$_FILES['image']['tmp_name']};type={$_FILES['image']['type']};filename={$_FILES['image']['name']}");
        $code = $tmhOAuth->request('POST', $tmhOAuth->url("1.1/account/update_profile_image"), $params, true, true);
        if ($code == 200) {
            $content = "<h2>Avatar Updated</h2>";
        } else {
            $content = "Damn! Something went wrong. Sorry :-(" . "<br /> code=" . $code . "<br /> status=" . $status . "<br /> image=" . $image . "</pre><br /> info=<pre>" . print_r($tmhOAuth->response['info'], true) . "</pre><br /> code=<pre>" . print_r($tmhOAuth->response['code'], true) . "</pre>";
        }
    }
    // Twitter API is really slow!  If there's no delay, the old profile is returned.
    //	Wait for 5 seconds before getting the user's information, which seems to be sufficient
    sleep(5);
    // retrieve profile information
    $user = twitter_user_info(user_current_username());
    $content .= theme('user_header', $user);
    $content .= theme('profile_form', $user);
    theme('page', "Edit Profile", $content);
}
开发者ID:shparvez001,项目名称:dabr,代码行数:33,代码来源:twitter.php

示例7: widget

 function widget($args, $instance)
 {
     $facebook = $instance['facebook'];
     $title = $instance['label'];
     $twitter = $instance['twitter'];
     $consumer_key = isset($instance['consumer_key']) ? $instance['consumer_key'] : '';
     $consumer_secret = isset($instance['consumer_secret']) ? $instance['consumer_secret'] : '';
     $access_token = isset($instance['access_token']) ? $instance['access_token'] : '';
     $access_token_secret = isset($instance['access_token_secret']) ? $instance['access_token_secret'] : '';
     $last_twitter_save = get_option('ts_last_twitter_follower_count_save_' . $twitter);
     $last_twitter_reponse = get_option('ts_last_twitter_follower_count_response_' . $twitter);
     $last_twitter_reponse = $last_twitter_reponse ? json_decode($last_twitter_reponse, true) : '';
     if ($last_twitter_save && time() - $last_twitter_save < 600 && $last_twitter_reponse && count($last_twitter_reponse) > 0) {
         //$last_twitter_reponse = json_decode($last_twitter_reponse, true);
     } else {
         $twitter_config = array('consumer_key' => $consumer_key, 'consumer_secret' => $consumer_secret, 'token' => $access_token, 'secret' => $access_token_secret);
         $tmhOAuth = new tmhOAuth($twitter_config);
         $params = array('screen_name' => $twitter);
         $code = $tmhOAuth->user_request(array('method' => 'GET', 'url' => $tmhOAuth->url("1.1/users/show"), 'params' => $params));
         if ($code == 200) {
             $last_twitter_reponse = $tmhOAuth->response['response'];
             $last_twitter_reponse_error = $last_twitter_reponse;
             update_option('ts_last_twitter_follower_count_save_' . $twitter, time());
             update_option('ts_last_twitter_follower_count_response_' . $twitter, $last_twitter_reponse);
             $last_twitter_reponse = json_decode($last_twitter_reponse, true);
         }
     }
     echo ts_essentials_escape($args['before_widget']);
     echo '<div class="inner clearfix">';
     if (!empty($title)) {
         echo ts_essentials_escape($args['before_title'] . apply_filters('widget_title', $title) . $args['after_title']);
     }
     if ($facebook) {
         $data = wp_remote_get('https://api.facebook.com/method/links.getStats?urls=' . urlencode('https://www.facebook.com/' . $facebook) . '&format=json');
         $fb_error = is_object($data) && get_class($data) == 'WP_Error' ? true : false;
         if (!$fb_error && isset($data['body'])) {
             $data = json_decode($data['body']);
             $data = isset($data[0]) && is_object($data[0]) ? $data[0] : $data;
             if (isset($data->like_count)) {
                 echo '<div class="inline-block"><a href="https://facebook.com/' . esc_attr($facebook) . '" class="facebook">';
                 echo '<i class="fa fa-facebook facebook-bg-color"></i>';
                 echo '<h4 class="sp1" title="' . esc_attr($data->like_count) . '">' . ts_essentials_num2str($data->like_count) . '</h4>';
                 echo '<span class="sp2 small">Likes</span>';
                 echo '</a></div>';
             }
         }
     }
     if ($twitter && is_array($last_twitter_reponse)) {
         $data = $last_twitter_reponse;
         if (isset($data['followers_count'])) {
             echo '<div class="inline-block"><a href="https://twitter.com/' . esc_attr($twitter) . '" class="twitter">';
             echo '<i class="fa fa-twitter twitter-bg-color"></i>';
             echo '<h4 class="sp1" title="' . esc_attr($data['followers_count']) . '">' . ts_essentials_num2str($data['followers_count']) . '</h4>';
             echo '<span class="sp2 small">Followers</span>';
             echo '</a></div>';
         }
     }
     echo '</div>';
     echo ts_essentials_escape($args['after_widget']);
 }
开发者ID:dqishmirian,项目名称:jrrny,代码行数:60,代码来源:facebook-twitter.php

示例8: getTweet

/**
* This method uses the Twitter API to get specified amount of Tweet Responses
* from Twitter for a specified Twitter User.
*
* @param screenName :: The Twitter Handle for which we require the tweets
* @param count :: The number of recent tweets needed for the Twitter User
*
* @return response :: Array of Twitter Response Objects
*/
function getTweet($screenName, $count)
{
    $parameters = array();
    $parameters['screen_name'] = $screenName;
    $parameters['count'] = $count;
    $connection = new tmhOAuth(array('consumer_key' => 'C8U6aOYWFkfuPxOiFBxoF87jF', 'consumer_secret' => 'cODzOUcJSqd3ATG15J25GXZlz7AyhK6gHbRCmsCiMIn0rfMKIu', 'user_token' => '2261472366-CPKf4pZ9fosiZ2zCQfXi7tiexIzbiNfzJ8lEcoC', 'user_secret' => 'gH6qWAAOCrmS38sf5ipaXIxHZHLHNGtYOmCZcJrFli0M9'));
    $twitterPath = '1.1/statuses/user_timeline.json';
    $http_code = $connection->request('GET', $connection->url($twitterPath), $parameters);
    // If everything is good
    if ($http_code === 200) {
        $response = strip_tags($connection->response['response']);
        $twitterResp = json_decode($response, true);
        // Log Success
        if (count($twitterResp) == 200) {
            logSuccess('tweetylogs.txt', 'Grabbed 200 Tweets for ' . $screenName . ' from the Twitter API.');
            logSuccess('success.txt', 'Grabbed 200 Tweets for ' . $screenName . ' from the Twitter API.');
            logSuccess('tweetylogs.html', 'Grabbed <b>200</b> Tweets for <b>' . $screenName . '</b> from the Twitter API.');
        } else {
            logWarning('tweetylogs.txt', 'Grabbed ' . (string) count($twitterResp) . ' Tweets for' . $screenName . ' from the Twitter API.');
            logWarning('warning.txt', 'Grabbed ' . (string) count($twitterResp) . ' Tweets for' . $screenName . ' from the Twitter API.');
            logWarning('tweetylogs.html', 'Grabbed <b>' . (string) count($twitterResp) . '</b> Tweets for <b>' . $screenName . '</b> from the Twitter API.');
        }
        return $twitterResp;
    } else {
        logError('tweetylogs.txt', 'Error in the function refreshData.php/getTweet() for Twitter User: ' . $screenName . '. HTTP Code not 200. HTTP Code/Error ID: ' . $http_code . '. Error: ' . $connection->response['error']);
        logError('error.txt', 'Error in the function refreshData.php/getTweet() for Twitter User: ' . $screenName . '. HTTP Code not 200. HTTP Code/Error ID: ' . $http_code . '. Error: ' . $connection->response['error']);
        logError('tweetylogs.html', 'Error in the function refreshData.php/getTweet() for Twitter User: <b>' . $screenName . '</b>. HTTP Code not 200. <b>HTTP Code/Error ID:</b> ' . $http_code . '. <b>Error:</b> ' . $connection->response['error']);
    }
}
开发者ID:vreddi,项目名称:twitterGame,代码行数:38,代码来源:refreshData.php

示例9: search

function search($idlist)
{
    global $twitter_keys, $current_key, $all_users, $all_tweet_ids, $bin_name, $dbh, $tweetQueue;
    $keyinfo = getRESTKey(0);
    $current_key = $keyinfo['key'];
    $ratefree = $keyinfo['remaining'];
    print "current key {$current_key} ratefree {$ratefree}\n";
    $tmhOAuth = new tmhOAuth(array('consumer_key' => $twitter_keys[$current_key]['twitter_consumer_key'], 'consumer_secret' => $twitter_keys[$current_key]['twitter_consumer_secret'], 'token' => $twitter_keys[$current_key]['twitter_user_token'], 'secret' => $twitter_keys[$current_key]['twitter_user_secret']));
    // by hundred
    for ($i = 0; $i < sizeof($idlist); $i += 100) {
        if ($ratefree <= 0 || $ratefree % 10 == 0) {
            $keyinfo = getRESTKey($current_key);
            $current_key = $keyinfo['key'];
            $ratefree = $keyinfo['remaining'];
            $tmhOAuth = new tmhOAuth(array('consumer_key' => $twitter_keys[$current_key]['twitter_consumer_key'], 'consumer_secret' => $twitter_keys[$current_key]['twitter_consumer_secret'], 'token' => $twitter_keys[$current_key]['twitter_user_token'], 'secret' => $twitter_keys[$current_key]['twitter_user_secret']));
        }
        $q = $idlist[$i];
        $n = $i + 1;
        while ($n < $i + 100) {
            if (!isset($idlist[$n])) {
                break;
            }
            $q .= "," . $idlist[$n];
            $n++;
        }
        $params = array('id' => $q);
        $code = $tmhOAuth->user_request(array('method' => 'GET', 'url' => $tmhOAuth->url('1.1/statuses/lookup'), 'params' => $params));
        $ratefree--;
        if ($tmhOAuth->response['code'] == 200) {
            $data = json_decode($tmhOAuth->response['response'], true);
            if (is_array($data) && empty($data)) {
                // all tweets in set are deleted
                continue;
            }
            $tweets = $data;
            $tweet_ids = array();
            foreach ($tweets as $tweet) {
                $t = new Tweet();
                $t->fromJSON($tweet);
                if (!$t->isInBin($bin_name)) {
                    $all_users[] = $t->from_user_id;
                    $all_tweet_ids[] = $t->id;
                    $tweet_ids[] = $t->id;
                    $tweetQueue->push($t, $bin_name);
                }
                print ".";
            }
            sleep(1);
        } else {
            echo "Failure with code " . $tmhOAuth->response['response']['code'] . "\n";
            var_dump($tmhOAuth->response['response']['info']);
            var_dump($tmhOAuth->response['response']['error']);
            var_dump($tmhOAuth->response['response']['errno']);
            die;
        }
        $tweetQueue->insertDB();
    }
}
开发者ID:01123578,项目名称:dmi-tcat,代码行数:58,代码来源:lookup.php

示例10: isAccessTokenValid

 /**
  * Checks if the authentication credentials currently stored in hydra.yml are correct or not.
  *
  * @return boolean
  */
 public function isAccessTokenValid()
 {
     if (empty($this->authentication['accessToken'])) {
         return false;
     }
     $this->api->request('GET', $this->api->url('v1/users/self/feed'), array('access_token' => $this->authentication['accessToken']));
     // HTTP 200 means we were successful
     return $this->api->response['code'] == 200;
 }
开发者ID:beecms,项目名称:virtual-identity,代码行数:14,代码来源:InstagramService.php

示例11: publish

 public function publish(ISocialStatus $status)
 {
     $params = array('status' => $status->getStatusString());
     $tmhOAuthEngine = new tmhOAuth($this->_config);
     $response = $tmhOAuthEngine->user_request(array('method' => 'POST', 'url' => $tmhOAuthEngine->url("1.1/statuses/update"), 'params' => $params, 'multipart' => true));
     if ($response != 200) {
         throw new Exception('Unable to publish on Twitter (ERR: ' . $response . ')');
     }
 }
开发者ID:ennio21,项目名称:php-social-publisher,代码行数:9,代码来源:TwitterPublisher.php

示例12: isAccessTokenValid

 /**
  * Checks if the authentication credentials currently stored in hydra.yml are correct or not.
  *
  * @return boolean
  */
 public function isAccessTokenValid()
 {
     if (empty($this->authentication['bearer'])) {
         return false;
     }
     $this->api->apponly_request(array('method' => 'GET', 'url' => $this->api->url('youtube/v3/activities', ''), 'params' => array('part' => 'id', 'mine' => 'true')));
     // HTTP 200 means we were successful
     return $this->api->response['code'] == 200;
 }
开发者ID:beecms,项目名称:virtual-identity,代码行数:14,代码来源:YoutubeService.php

示例13: get_twitter_timeline

function get_twitter_timeline($user)
{
    //global $user;
    $tmhOAuth = new tmhOAuth(array('consumer_key' => CONSUMER_KEY, 'consumer_secret' => CONSUMER_SECRET, 'token' => USER_TOKEN, 'secret' => USER_SECRET));
    if ($tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline.json'), array('include_entities' => 'false', 'include_rts' => 'false', 'trim_user' => 'true', 'screen_name' => $user, 'exclude_replies' => 'false', 'count' => TL_COUNT), true) != 200) {
        header("Content-Type: text/html; charset=utf-8");
        die('Could not connect to Twitter');
    }
    return json_decode($tmhOAuth->response['response'], true);
}
开发者ID:puteulanus,项目名称:smzdm_monitor,代码行数:10,代码来源:function.inc.php

示例14: search

function search($keywords, $max_id = null)
{
    global $twitter_keys, $current_key, $ratefree, $bin_name, $dbh, $tweetQueue;
    $ratefree--;
    if ($ratefree < 1 || $ratefree % 10 == 0) {
        $keyinfo = getRESTKey($current_key, 'search', 'tweets');
        $current_key = $keyinfo['key'];
        $ratefree = $keyinfo['remaining'];
    }
    $tmhOAuth = new tmhOAuth(array('consumer_key' => $twitter_keys[$current_key]['twitter_consumer_key'], 'consumer_secret' => $twitter_keys[$current_key]['twitter_consumer_secret'], 'token' => $twitter_keys[$current_key]['twitter_user_token'], 'secret' => $twitter_keys[$current_key]['twitter_user_secret']));
    $params = array('q' => $keywords, 'count' => 100);
    if (isset($max_id)) {
        $params['max_id'] = $max_id;
    }
    $code = $tmhOAuth->user_request(array('method' => 'GET', 'url' => $tmhOAuth->url('1.1/search/tweets'), 'params' => $params));
    if ($tmhOAuth->response['code'] == 200) {
        $data = json_decode($tmhOAuth->response['response'], true);
        $tweets = $data['statuses'];
        $tweet_ids = array();
        foreach ($tweets as $tweet) {
            $t = new Tweet();
            $t->fromJSON($tweet);
            $tweet_ids[] = $t->id;
            if (!$t->isInBin($bin_name)) {
                $tweetQueue->push($t, $bin_name);
                if ($tweetQueue->length() > 100) {
                    $tweetQueue->insertDB();
                }
                print ".";
            }
        }
        if (!empty($tweet_ids)) {
            print "\n";
            if (count($tweet_ids) <= 1) {
                print "no more tweets found\n\n";
                return false;
            }
            $max_id = min($tweet_ids);
            print "max id: " . $max_id . "\n";
        } else {
            print "0 tweets found\n\n";
            return false;
        }
        sleep(1);
        search($keywords, $max_id);
    } else {
        echo $tmhOAuth->response['response'] . "\n";
        if ($tmhOAuth->response['response']['errors']['code'] == 130) {
            // over capacity
            sleep(1);
            search($keywords, $max_id);
        }
    }
}
开发者ID:petethegreek,项目名称:dmi-tcat,代码行数:54,代码来源:search.php

示例15: tweetFromCoffeeMachine

function tweetFromCoffeeMachine($message)
{
    $tmhOAuth = new tmhOAuth(array('consumer_key' => 'yBqPMCfmM59Rbglvz1Ulaw', 'consumer_secret' => 'emXtf7PDoYURANce1RqRE2FaZpgJeaQixRlCafpQ0', 'user_token' => '576073937-gZokaOQgJwY3U64frIV1MkzHfnelx3XvxMC2FHOM', 'user_secret' => 'ursK27EZa2nZliVBBFdfEjpiTwMkqdQoqpnTZG07Sgc'));
    $code = $tmhOAuth->request('POST', $tmhOAuth->url('1/statuses/update'), array('status' => $message));
    /* don't care about the response in this case
    	if ($code == 200) {
    	  tmhUtilities::pr(json_decode($tmhOAuth->response['response']));
    	} else {
    	  tmhUtilities::pr($tmhOAuth->response['response']);
    	}*/
}
开发者ID:newtonsheesha,项目名称:RFIDCheckinSystem,代码行数:11,代码来源:tweet.php


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