PHP SDK Demystified – the $DOMAIN_MAP Property

In the PHP SDK code, after the cURL options is the $DROP_QUERY_PARAMS property:

  /**
   * Maps aliases to Facebook domains.
   */
  public static $DOMAIN_MAP = array(
    'api'      => 'https://api.facebook.com/',
    'api_read' => 'https://api-read.facebook.com/',
    'graph'    => 'https://graph.facebook.com/',
    'www'      => 'https://www.facebook.com/',
  );

The $DOMAIN_MAP property contains the key-value mappings of the commonly used domains where HTTP requests are to send to. Among then

  • api
    This is where to send out the Old REST API “write” requests to
  • api_read
    This is where to send out the Old REST API “read” requests to.
  • graph
    This is where to send out the Graph API requests.
  • www
    This is the general facebook domain where login.php, logout.php reside.

Among the above values, the only point that I would like to draw your attention is the “api_read”.  It is pointing to ‘https://api-read.facebook.com/’.  However, there are some servers that get problem in resolving this domain name.  Just in case this happens to you, please modify it so that it point to ‘https://api.facebook.com/’. For details, please see my tutorial Learning PHP SDK – Part 7 (Calling old REST API).

The $DOMAIN_MAP is only used in the protected function getUrl(). In short, the getUrl function is for building a URL by using the given domain alias (i.e. the element keys in the $DOMAIN_MAP), path and parameters.  We will have a more detailed discussion on that later.

This entry was posted in PHP SDK Demystified and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *