protected function Instagram::request in Drupagram 6
Same name and namespace in other branches
- 7 drupagram.lib.php \Instagram::request()
Perform a request
Parameters
string $url:
array $params:
string $method. Can be one of: GET, POST, DELETE or PUT.:
bool $use_auth:
Return value
type
3 calls to Instagram::request()
- Instagram::auth_request in ./
drupagram.lib.php - Perform an authentication required request.
- Instagram::call in ./
drupagram.lib.php - Method for calling any drupagram api resource
- InstagramOAuth::auth_request in ./
drupagram.lib.php - Perform an authentication required request.
File
- ./
drupagram.lib.php, line 229 - Classes to implement the full Instagram API
Class
- Primary Instagram API implementation class Supports the full REST API for drupagram.
Code
protected function request($url, $params = array(), $method = 'GET', $use_auth = FALSE) {
$data = '';
if (!is_array($params)) {
$params = (array) $params;
}
if (count($params) > 0) {
if ($method == 'GET') {
if (is_array($params) && !empty($params)) {
$url = t($url, $params);
}
$url = preg_replace('/&?[a-z_]*=![a-z_]*/', '', $url, -1);
}
else {
$data = http_build_query($params, '', '&');
}
}
$headers = array();
$response = drupal_http_request($url, $headers, $method, $data, 3, 30);
if (!isset($response->error)) {
return $response->data;
}
else {
throw new InstagramException($response->error);
}
}