You are here

public static function ShareaholicHttp::send in Share Buttons, Related Posts, Content Analytics - Shareaholic 7.3

Same name in this branch
  1. 7.3 lib/social-share-counts/http.php \ShareaholicHttp::send()
  2. 7.3 lib/social-share-counts/drupal_http.php \ShareaholicHttp::send()
  3. 7.3 lib/social-share-counts/wordpress_http.php \ShareaholicHttp::send()
Same name and namespace in other branches
  1. 8 lib/social-share-counts/http.php \ShareaholicHttp::send()
  2. 8 lib/social-share-counts/drupal_http.php \ShareaholicHttp::send()
  3. 8 lib/social-share-counts/wordpress_http.php \ShareaholicHttp::send()

Performs a HTTP request with a url, array of options, and ignore_error flag

The options object is an associative array that takes the following options:

  • method: The http method for the request as a string. Defaults is 'GET'.
  • headers: The headers to send with the request as an associative array of name/value pairs. Default is empty array.
  • body: The body to send with the request as an associative array of name/value pairs. Default is NULL.

If the body is meant to be parsed as json, specify the content type in the headers option to be 'application/json'.

  • redirection: The number of redirects to follow for this request as an integer, Default is 5.
  • timeout: The number of seconds the request should take as an integer. Default is 15 (seconds).
  • user-agent: The useragent for the request. Default is mozilla browser useragent.

This function returns an object on success or false if there were errors. The object is an associative array with the following keys:

  • headers: the response headers as an array of key/value pairs
  • body: the response body as a string
  • response: an array with the following keys:
    • code: the response code
    • message: the status message

Parameters

string $url The url you are sending the request to:

array $options An array of supported options to pass to the request:

bool $ignore_error A flag indicating to log error or not. Default is false.:

Return value

mixed It returns an associative array of name value pairs or false if there was an error.

4 calls to ShareaholicHttp::send()
ShareaholicSeqShareCount::get_counts in lib/social-share-counts/seq_share_count.php
This function should get all the counts for the supported services
ShareaholicUtilities::connectivity_check in ./utilities.php
Server Connectivity check
ShareaholicUtilities::log_event in ./utilities.php
This is a wrapper for the Event API
ShareaholicUtilities::share_counts_api_connectivity_check in ./utilities.php
Share Counts API Connectivity check

File

lib/social-share-counts/wordpress_http.php, line 52

Class

ShareaholicHttp
The purpose of this class is to provide an interface around any native http function (wp_remote_get, drupal_http_request, curl) so that one use this consistent API for making http request with well defined input and output.

Code

public static function send($url, $options = array(), $ignore_error = false) {
  return self::send_with_wp($url, $options, $ignore_error);
}