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


PHP HTTP::request方法代码示例

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


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

示例1: send_message_to_third_party

 public function send_message_to_third_party($account_id, $post_data)
 {
     if (!$account_id or !$post_data) {
         return false;
     }
     $rules = $this->get_third_party_api_by_account_id($account_id, true, 'rank ASC');
     if (!$rules) {
         return false;
     }
     $timestamp = time();
     $nonce = mt_rand(1000000000, 9999999999);
     foreach ($rules as $rule) {
         if (!$rule['url'] or !$rule['token']) {
             continue;
         }
         $signature = $this->model('weixin')->generate_signature($rule['token'], $timestamp, $nonce);
         if (!$signature) {
             continue;
         }
         $url = $rule['url'] . '?signature=' . $signature . '&timestamp=' . $timestamp . '&nonce=' . $nonce;
         $response = HTTP::request($url, 'POST', $post_data, 5);
         if ($response) {
             return $response;
         }
     }
     return false;
 }
开发者ID:Gradven,项目名称:what3.1.7,代码行数:27,代码来源:third.php

示例2: douban

 public function douban()
 {
     if ($this->request->get("code")) {
         //已获得code
         $code = $this->request->get("code");
         $params = array('client_id' => DOUBAN_CLIENT_ID, 'client_secret' => DOUBAN_CLIENT_SECRET, 'redirect_uri' => $this->_siteUrl . DOUBAN_REDIRECT_URI, 'grant_type' => 'authorization_code', 'code' => $code);
         $result = json_decode(HTTP::request(DOUBAN_ACCESS_TOKEN_URL, $params, 'POST'));
         if (!isset($result->code)) {
             $set = array('douban_access_token' => $result->access_token, 'douban_refresh_token' => $result->refresh_token, 'douban_expires_in' => $result->expires_in, 'douban_last_time' => time() + $result->expires_in);
             Widget_Plugins_Edit::configPlugin("SyncPost", $set);
             $this->widget('Widget_Notice')->set(_t('豆瓣广播授权成功!'), 'success');
         } else {
             $this->widget('Widget_Notice')->set(_t('豆瓣广播授权失败,异常信息:' . $result->code . ' - ' . $result->msg), 'error');
         }
         header('Location: ' . $this->_siteUrl . __TYPECHO_ADMIN_DIR__ . 'options-plugin.php?config=SyncPost');
         //刷新页面
     } else {
         //获取授权code
         $params = array('client_id' => DOUBAN_CLIENT_ID, 'redirect_uri' => $this->_siteUrl . DOUBAN_REDIRECT_URI, 'response_type' => 'code');
         header('Location: ' . DOUBAN_AUTHORIZATION_CODE_URL . '?' . http_build_query($params));
         //刷新页面
     }
 }
开发者ID:duxiangfei,项目名称:plugins,代码行数:23,代码来源:Action.php

示例3: upload_file

 public function upload_file($file, $type)
 {
     $app_id = get_setting('weixin_app_id');
     $app_secret = get_setting('weixin_app_secret');
     $file = realpath($file);
     if (!is_readable($file)) {
         return false;
     }
     $file_md5 = md5_file($file);
     $cached_result = AWS_APP::cache()->get('weixin_upload_file_' . $file_md5);
     if ($cached_result) {
         return $cached_result;
     }
     $post_data = array('media' => '@' . $file);
     $result = HTTP::request(self::WEIXIN_FILE_API . 'media/upload?access_token=' . $this->get_access_token($app_id, $app_secret) . '&type=' . $type, 'POST', $post_data);
     if (!$result) {
         return false;
     }
     $result = json_decode($result, true);
     if ($result['errcode']) {
         if ($result['errcode'] == 40001) {
             $this->refresh_access_token($app_id, $app_secret);
             return $this->upload_file($file, $type);
         }
     } else {
         AWS_APP::cache()->set('weixin_upload_file_' . $file_md5, $result, 259200);
     }
     return $result;
 }
开发者ID:ddxmaaa,项目名称:wecenter-loudong,代码行数:29,代码来源:weixin.php

示例4: create_comment

 public function create_comment($access_token, $id, $comment)
 {
     if (!$access_token) {
         return false;
     }
     $args = array('access_token' => $access_token, 'comment' => $comment, 'id' => $id);
     $result = HTTP::request(self::COMMENTS_CREATE_URL, 'POST', http_build_query($args));
     if (!$result) {
         return false;
     }
     return json_decode($result, true);
 }
开发者ID:egogg,项目名称:wecenter-dev,代码行数:12,代码来源:oauth.php

示例5: refresh_access_token

 public function refresh_access_token($uid)
 {
     $user_info = $this->get_facebook_user_by_uid($uid);
     if (!$user_info) {
         $this->error_msg = AWS_APP::lang()->_t('Facebook 账号未绑定');
         return false;
     }
     if (!$user_info['access_token']) {
         $this->error_msg = AWS_APP::lang()->_t('user access token 为空');
         return false;
     }
     $args = array('client_id' => get_setting('facebook_app_id'), 'client_secret' => get_setting('facebook_app_secret'), 'refresh_token' => htmlspecialchars_decode($user_info['refresh_token']), 'grant_type' => 'refresh_token');
     $result = HTTP::request(self::OAUTH2_TOKEN_URL, 'POST', $args);
     if (!$result) {
         $this->error_msg = AWS_APP::lang()->_t('更新 access token 时,与 Facebook 通信失败');
         return false;
     }
     $result = json_decode($result, true);
     if ($result['error']) {
         if (!$result['error_description']) {
             $result['error_description'] = $result['error'];
         }
         $this->error_msg = AWS_APP::lang()->_t('更新 access token 失败,错误为:%s', $result['error_description']);
         return false;
     }
     $this->update('users_facebook', array('access_token' => htmlspecialchars($result['access_token']), 'expires_time' => time() + intval($result['expires_in'])), 'id = ' . $user_info['id']);
     return true;
 }
开发者ID:egogg,项目名称:wecenter-dev,代码行数:28,代码来源:facebook.php

示例6: postRender

 public static function postRender($contents, $class)
 {
     //echo '<xmp>';
     //var_dump($contents);
     //exit();
     if ($class->request->is('do=publish')) {
         $opstions = Helper::options()->plugin('SyncPost');
         $syncpost = $class->request->get('syncpost');
         foreach ((array) $syncpost as $key => $val) {
             if ($val == 'syncpost-tqq') {
                 $params = array('oauth_consumer_key' => TQQ_CLIENT_ID, 'access_token' => $opstions->tqq_access_token, 'openid' => $opstions->tqq_openid, 'oauth_version' => '2.a', 'format' => 'json', 'content' => str_replace(array('%title%', '%permalink%'), array($contents['title'], $class->permalink), $opstions->postContent));
                 $result = HTTP::request(TQQ_API_URL, $params, 'POST');
             } else {
                 if ($val == 'syncpost-sina') {
                     $params = array('access_token' => $opstions->sina_access_token, 'status' => str_replace(array('%title%', '%permalink%'), array($contents['title'], $class->permalink), $opstions->postContent));
                     $result = HTTP::request(SINA_API_URL, $params, 'POST');
                 } else {
                     if ($val == 'syncpost-douban') {
                         $params = array('source' => $opstions->douban_access_token, 'text' => str_replace(array('%title%', '%permalink%'), array($contents['title'], $class->permalink), $opstions->postContent));
                         $result = HTTP::request(DOUBAN_API_URL, $params, 'POST', false, array('Authorization: Bearer ' . $opstions->douban_access_token));
                     }
                 }
             }
         }
     }
     return $contents;
 }
开发者ID:duxiangfei,项目名称:plugins,代码行数:27,代码来源:Plugin.php

示例7: verify_credentials

 public function verify_credentials()
 {
     $args = array('oauth_token' => $this->access_token['oauth_token'], 'oauth_token_secret' => $this->access_token['oauth_token_secret']);
     $header = array($this->build_auth_header($args, self::OAUTH_AUTH_VALIDATION_URL, 'GET'));
     $result = HTTP::request(self::OAUTH_AUTH_VALIDATION_URL, 'GET', null, 10, $header);
     if (!$result) {
         $this->error_msg = AWS_APP::lang()->_t('获取个人资料时,与 Twitter 通信失败');
         return false;
     }
     $result = json_decode($result, true);
     if ($result['errors']) {
         $this->error_msg = AWS_APP::lang()->_t('获取个人资料失败,错误为:%s', $result['errors']['message']);
         return false;
     }
     $this->user_info = array('id' => $result['id'], 'name' => $result['name'], 'screen_name' => $result['screen_name'], 'location' => $result['location'], 'time_zone' => $result['time_zone'], 'lang' => $result['lang'], 'profile_image_url' => str_ireplace('_normal.', '_400x400.', $result['profile_image_url']), 'access_token' => array('oauth_token' => $this->access_token['oauth_token'], 'oauth_token_secret' => $this->access_token['oauth_token_secret']));
     return true;
 }
开发者ID:Gradven,项目名称:what3.1.7,代码行数:17,代码来源:twitter.php


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