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


PHP Facebook::makeRequest方法代码示例

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


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

示例1: makeRequest

 /**
  * Overrides the Facebook API request methods, so we can use vUrl
  *
  * @param String $url the URL to make the request to
  * @param Array $params the parameters to use for the POST body
  * @param CurlHandler $ch optional initialized curl handle
  * @return String the response text
  */
 protected function makeRequest($url, $params, $ch = null)
 {
     // try Facebook's cURL implementation (including the new bundled certificates)
     if (function_exists('curl_init')) {
         try {
             $result = parent::makeRequest($url, $params, $ch);
         } catch (Exception $e) {
             $result = false;
         }
         if ($result) {
             return $result;
         }
     }
     // use vB_vURL implmentation
     global $vbulletin;
     $opts = self::$CURL_OPTS;
     require_once DIR . '/includes/class_vurl.php';
     $vurl = new vB_vURL($vbulletin);
     $vurl->set_option(VURL_URL, $url);
     $vurl->set_option(VURL_CONNECTTIMEOUT, $opts[CURLOPT_CONNECTTIMEOUT]);
     $vurl->set_option(VURL_TIMEOUT, $opts[CURLOPT_TIMEOUT]);
     $vurl->set_option(VURL_POST, 1);
     // If we want to use more advanced features such as uploading pictures
     // to facebook, we may need to remove http_build_query and refactor
     // vB_vURL to accept an array of POST data and send the multipart/form-data
     // Content-Type header.
     $vurl->set_option(VURL_POSTFIELDS, http_build_query($params, '', '&'));
     $vurl->set_option(VURL_RETURNTRANSFER, $opts[CURLOPT_RETURNTRANSFER]);
     $vurl->set_option(VURL_CLOSECONNECTION, $opts[CURLOPT_RETURNTRANSFER]);
     $vurl->set_option(VURL_USERAGENT, $opts[CURLOPT_USERAGENT]);
     $result = $vurl->exec();
     // TODO: add some error checking here
     // particularly check if $vurl->fetch_error() returns VURL_ERROR_SSL, meaning the server
     // does not have access to TLS/SSL with which to communicate with facebook
     return $result;
 }
开发者ID:0hyeah,项目名称:yurivn,代码行数:44,代码来源:class_facebook.php

示例2: loginFacebook

 /**
  * Login con facebook
  * */
 public function loginFacebook()
 {
     try {
         $obj = new \Facebook($this->facebook_id, $this->facebook_secret, $this->callback_url);
         $token = $obj->callback();
         if (!$token) {
             $this->last_error = "oauth-facebook-access-denied";
             return false;
         }
         $this->tokens['facebook']['token'] = $token;
         //print_R($token);
         //echo 'facebook_access_token: ' . $token;
         //guardar los tokens en la base datos si se quieren usar mas adelante!
         //con los tokens podems acceder a la info del user, hay que recrear el objecto con los tokens privados
         $res = json_decode($obj->makeRequest($token, "https://graph.facebook.com/me", "GET"));
         if ($res->error) {
             $this->last_error = $res->error->message;
             return false;
         }
         //ver todos los datos disponibles:
         //print_r($res);die;
         $this->user_data['name'] = $res->name;
         if ($res->username) {
             $this->user_data['username'] = $res->username;
         }
         if ($res->email) {
             $this->user_data['email'] = $res->email;
         }
         if ($res->website) {
             $this->user_data['website'] = $res->website;
         }
         //ojo, pueden ser varias lineas con varias webs
         if ($res->about) {
             $this->user_data['about'] = $res->about;
         }
         if ($res->location->name) {
             $this->user_data['location'] = $res->location->name;
         }
         if ($res->id) {
             $this->user_data['profile_image_url'] = "http://graph.facebook.com/" . $res->id . "/picture?type=large";
         }
         //facebook link
         if ($res->link) {
             $this->user_data['facebook'] = $res->link;
         }
         return true;
     } catch (Exception $e) {
         $this->last_error = $e->getMessage() . " 1/ " . get_class($e);
         return false;
     }
     return true;
 }
开发者ID:anvnguyen,项目名称:Goteo,代码行数:55,代码来源:SocialAuth.php


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