HomeSupportSample PHP Client Library Reference

Overview

This Sample Client Library (language binding) can be used to interact with the Brafton API in an object oriented manner using PHP code. The library wraps up sending requests and parsing the XML responses into objects.

Compatible with: PHP5

[Jump to top]

Download

[Jump to top]

Example

include_once 'Sample_Php_ApiClientLibrary/ApiHandler.php'; //reference to Sample php client library you downloaded from above.

//Feed Configuration
$API_Key = "YOUR_API_KEY"; // your unique API_Key as provided via email
$apiBaseUrl = "YOUR_API_BASE_URL"; // your API base URL as provided via email
$feed = new ApiHandler($API_Key, $apiBaseUrl); //create a new feed object
$newsList = $feed->getNewsHTML(); //return an array of your latest news items with HTML encoding text. Note this is still raw data.

[Jump to top]

APIHandler Class Reference

This is the main class which provides the core methods to interact with your feed and return several collections of objects related to your feed i.e. news items, category definitions and latest comments.

[ Constructor ]

ApiHandler($API_key, $apiBaseUrl)

  • Description: APIHandler Class contructor.
  • Parameter – $API_key: your unique API key.
  • Parameter – $apiBaseUrl: the base url provided to you
  • Exceptions: XMLLoadException
[ News Functions ]

getNewsHTML()

  • Description: get an array of news item objects for the feed with the body content in HTML format
  • return values: array of NewsItem

getNewsRaw()

  • Description: get an array of news item objects for the feed with the body content in Raw text
  • return values: array of NewsItem
[ Category Functions ]

getCategoryDefinitions()

  • Description: return an array of all the category objects defined for the feed
  • return values: array of NewsCategory
[ Comment Functions ]

getLatestComments()

  • Description: get an array of all the latest comments on news items for the feed
  • return values: array of NewsComment

[Jump to top]

newsItem Class Reference

[ Properties ]
  • getByLine(): String – author of the news article
  • getCategories(): Category[] – array of category objects associated with the news article
  • getClientQuote(): String – quote text from the client relating to this item.
  • getComments(): Comment[] – array of comment objects associated with the news article
  • getCreatedDate: String – ISO 8601 system autogenerated date when the item was created
  • getEncoding(): String – character encoding system used eg. UTF-8
  • getExtract(): String – a summary of the news article
  • getFormat(): String – format of text content either HTML or RAW
  • getHeadline(): String – the news article headline
  • getHtmlMetaDescription(): String – value for the description meta tag for the news article
  • getHtmlMetaKeywords(): String – value for the keywords meta tag for the news article
  • getHtmlMetaLanguage(): String – value for the language meta tag of the news article
  • getHtmlTitle(): String – value for the html title element
  • getId(): int – primary key. the unique news article id
  • getLastModifiedDate():: String – ISO 8601 date article was last modified
  • getPhotos():IEnumerable

    – array of photo objects associated with the news article

  • getPriority(): int – priority flag 30 = high, normal = 20 used to prioritise news
  • getPublishDate(): String – ISO 8601 date article was published
  • getSource(): String – original source of the article
  • getState(): String – current state of the article eg LIVE / APPROVAL / DRAFT / DELETED
  • getTags(): String – a comma separated list of free text tags
  • getText(): String – text content of the news article
  • getTweetText(): String – special 140 character twitter version of the news article

[Jump to top]

NewsCategory Class Reference

[ Properties ]
  • getId(): int – the unique category id
  • getName(): String – the text name of the category

[Jump to top]

Photo Class Reference

[ Properties ]
  • getAlt(): String – text which can be used in the alternative text attribute for the image
  • getCustom(): PhotoInstance – get Custom PhotoInstance of the photograph
  • getHiRes(): PhotoInstance – get High Resolution PhotoInstance of the photograph
  • getId(): int – the unique photo id
  • getLarge(): PhotoInstance – get Large PhotoInstance of the photograph
  • getOrientation(): String – orientation of photo either PORTRAIT or LANDSCAPE
  • getThumb(): PhotoInstance – get Thumbnail PhotoInstance of the photograph

[Jump to top]

PhotoInstance Class Reference

[ Properties ]
  • getHeight(): int – the height in pixels of this instance of the image
  • getUrl(): String – the URL that points to the source location of this instance of the image
  • getWidth(): int – the width in pixels of this instance of the image

[Jump to top]

NewsComment Class Reference

[ Properties ]
  • getCommentTxt(): String – the comment text
  • getId(): int – the unique comment id
  • getLocation(): String – geographic location information for the comment
  • getPostDate(): String – ISO 8601 date when the comment was submitted
  • getUser(): String – name of commentor

[Jump to top]