예제 #1
0
 /**
  * Makes a signed_request blob using the given data.
  *
  * @param array $data The data array.
  * @param string $appSecret
  * @throws InvalidArgumentException
  * @return string The signed request.
  */
 public static function encode($data, $appSecret)
 {
     if (!is_array($data)) {
         throw new InvalidArgumentException(__METHOD__ . ' expects an array, but given ' . print_r($data, TRUE));
     }
     $data['algorithm'] = Configuration::SIGNED_REQUEST_ALGORITHM;
     $data['issued_at'] = time();
     $b64 = Helpers::base64UrlEncode(Json::encode($data));
     $raw_sig = hash_hmac('sha256', $b64, $appSecret, $raw = TRUE);
     $sig = Helpers::base64UrlEncode($raw_sig);
     return $sig . '.' . $b64;
 }
예제 #2
0
 /**
  * Invoke the Graph API.
  *
  * @param string $path The path (required)
  * @param string $method The http method (default 'GET')
  * @param array $params The query/post data
  * @throws Facebook\FacebookApiException
  * @return mixed The decoded response object
  */
 public function graph($path, $method = NULL, array $params = array())
 {
     if (is_array($method) && empty($params)) {
         $params = $method;
         $method = NULL;
     }
     $params['method'] = $method ?: 'GET';
     // method override as we always do a POST
     $domainKey = Facebook\Helpers::isVideoPost($path, $method) ? 'graph_video' : 'graph';
     return $this->callOauth($this->fb->config->createUrl($domainKey, $path), $params);
 }
예제 #3
0
 /**
  * Invoke the Graph API.
  *
  * @param string $path The path (required)
  * @param string $method The http method (default 'GET')
  * @param array $params The query/post data
  * @throws Facebook\FacebookApiException
  * @return mixed The decoded response object
  */
 public function graph($path, $method = NULL, array $params = array())
 {
     if (is_array($method) && empty($params)) {
         $params = $method;
         $method = NULL;
     }
     if (($i = strpos($path, '?')) !== FALSE) {
         parse_str(substr($path, $i + 1), $tmp);
         $params += $tmp;
         $path = substr($path, 0, $i);
     }
     $params['method'] = $method ?: 'GET';
     // method override as we always do a POST
     $domainKey = Facebook\Helpers::isVideoPost($path, $method) ? 'graph_video' : 'graph';
     return $this->callOauth($this->fb->config->createUrl($domainKey, $path), $params);
 }