Download the PHP package stackla/stackla-php-sdk without Composer
On this page you can find all versions of the php package stackla/stackla-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package stackla-php-sdk
Stackla PHP SDK
Copyright © 2012 to present. Stackla, Inc., Stackla Pty Ltd., and Stackla Ltd. All rights reserved.
Welcome to the Stackla PHP SDK GitHub repository!
This SDK is intended for PHP developers to enable them to integrate Stackla RESTful APIs into their applications with greater ease. You can find more information on working with Stackla APIs on the Stackla Developer Portal.
We are continuously working on improving both the SDK and the documentation around it, so please feel free to give us feedback and any reports of issues to [email protected].
System requirements
- PHP >= 5.4
- Composer
PHPUnit
Required env
variable:
- ACCESS_TOKEN
- API_STACK => Stackla stack short_name
- API_HOST =>
https://api.stackla.com/api/
- DEFAULT_FILTER_ID
- DEFAULT TAG_ID
- STACKLA_POST_TERM_ID
Great. How do I get this thing going?
Dependencies
Include this package in your composer.json:
And then:
Instantiating a Stack
There are 2 ways to connect to Stackla: OAuth2 or the previous _apikey method The _apikey method is being deprecated over time in favour of the OAuth2 method.
OAuth2 (access_token)
This is the preferred method and is being rolled out to all customers at present.
Generate OAuth2 access token
If you are developing a custom application that will have a client ID, users will need to authenticate and authorise the use their account in order for you to obtain a token. If you are not developing a custom app, may not need to perform this part.
To generate the token, you can generate the OAuth2 callback endpoint for your application as per the following.
link.php
callback.php
More details
API Key (api_key)
This method is being deprecated. Please contact your customer representative if you are using or intend to use this method.
Object Reference
Term
Properties
Property | type | value | Post | Put | Definition | |
---|---|---|---|---|---|---|
id | ✘ | ✘ | unique id for term | |||
name | ✔ | ✔ | Name this new term | |||
display_name | ✔ | ✔ | string | Display name | ||
active | ✔ | ✔ | Flag - 1 or 0 | |||
type** | ✔ | ✘ | ||||
network** | ✔ | ✘ | ||||
term* | ✔ | ✔ | keyword for the term | |||
filter | ✔ | ✔ | Filter CSV list | |||
exclude_filter | ✔ | ✔ | Exclude-filter CSV list | |||
fan_filter | ✔ | ✔ | Fan-filter CSV list | |||
fan_exclude_filter | ✔ | ✔ | Fan-exclude-filter CSV list | |||
minimum_fallowers | ✔ | ✔ | Threshorld for minimum followers, available only for twitter - search and hashtag terms | |||
moderate_text | ✔ | ✔ | value wil be either | |||
moderate_image | ✔ | ✔ | same as moderate_text value | |||
moderate_video | ✔ | ✔ | same as moderate_text value | |||
retweet_enable | ✔ | ✔ | ||||
reply_enable | ✔ | ✔ | ||||
reply_to_enable | ✔ | ✔ | ||||
partial_match | ✔ | ✔ | ||||
include_fan_content | ✔ | ✔ | ||||
include_hashtag_in_comments | ✔ | ✔ | ||||
include_official_content | ✔ | ✔ | ||||
search_exact_phrase | ✔ | ✔ | ||||
num_of_backfill | ✔ | ✘ | ||||
whitelist_handles | ✔ | ✔ | ||||
blacklist_handles | ✔ | ✔ | ||||
avatar | ✔ | ✔ | ||||
source_user_id | ✔ | ✔ | ||||
tags | ✔ | ✔ | listing of tag | |||
created | ✘ | ✘ | Term's creation time | |||
modified | ✘ | ✘ | Term's modification time | |||
last_ingestion_post | ✘ | ✘ | Term's last ingestion post time |
Methods
Method | argument | type | default | return |
---|---|---|---|---|
create | - | - | - | self or false |
update | false | self or false | ||
get | Term objects / self or false | |||
getById | - | Term object / self or false | ||
delete | - | - | - | self or false |
addTag*** | - | Term / it self | ||
deleteTag*** | - | Term / it self | ||
associateTag**** | - | Term / it self | ||
disassociateTag**** | - | Term / it self |
Notes
- When creating a new facebook term or twitter user term or instagram user term or pinterest user term or gplus user term or flickr user term, this method will validate the user first.
- After term creation, the and cannot be changed and if it passes, the term will be created. Alternatively, it will return an error when the the user validation has failed.
- These methods are only adding/deleting tag from the properties. You still need to call update.
- Remember to call this method after the term is created. These methods will send a request to RESTful API, there is NO need to call update.
Examples
Create a new instance of term object:
Create a new term:
Get term:
Looping through array of terms:
Update the term:
Add and delete tags:
Delete Term: ```#!php // Create new instance of term object with term id and pull from API $term = $stack->instance('term', 1234);
// Delete term $term->delete();
Catch errors:
```#!php
$term = $stack->instance('term');
try {
$term->update();
} catch (\Exception $e) {
echo $e->getMessage();
}
Filter
Properties
Property | type | value | Post | Put | Definition |
---|---|---|---|---|---|
id | integer |
✘ | ✘ | unique id for filter | |
name | string |
✔ | ✔ | filter name | |
enable | enum | Filter::ENABLE_HIDDEN Filter::ENABLE_PANEL Filter::ENABLE_BAR |
✔ | ✔ | status to show filter in Social hub | |
order | integer |
✔ | ✔ | order of filter in Social hub | |
sort | enum | Filter::SORT_LATEST Filter::SORT_GREATEST Filter::SORT_MOST_VOTES |
✔ | ✔ | filter sorting type | |
networks | enum[] | Stackla::NETWORK_TWITTER Stackla::NETWORK_FACEBOOK Stackla::NETWORK_INSTAGRAM Stackla::NETWORK_YOUTUBE Stackla::NETWORK_GPLUS Stackla::NETWORK_FLICKR Stackla::NETWORK_PINTEREST Stackla::NETWORK_TUMBLR Stackla::NETWORK_RSS Stackla::NETWORK_ECAL Stackla::NETWORK_STACKLA Stackla::NETWORK_WEIBO |
✔ | ✔ | filtering network(s) | |
tags | Tag[] |
✔ | ✔ | filtering tag(s) | |
media | enum[] | Filter::MEDIA_TEXT Filter::MEDIA_IMAGE Filter::MEDIA_VIDEO Filter::MEDIA_HTML |
✔ | ✔ | filtering media(s) |
Methods
Method | argument | type | default | return |
---|---|---|---|---|
create* | - | - | - | self or false |
update | $force | bool | false |
self or false | ||
get | $limit $page $options | integer integer array | 25 1 [] |
|||
getById | $id | integer |
- | Filter[] or false | |
getContents | $force | boolean | false |
false or Tile[] | ||
getContents | $limit $force | integer boolean | 25 false |
false or Tile[] | ||
getContents | $limit $options $force | integer array boolean | 25 [] false |
false or Tile[] | ||
getContents | $limit $page $force | integer integer boolean | 25 1 false |
false or Tile[] | ||
getContents | $limit $page $options $force | integer integer array boolean | 25 1 [] false |
false or Tile[] | ||
delete | - | - | - | self or false |
Tile
Properties
Property | type | value | Post | Put | Definition |
---|---|---|---|---|---|
id | string |
✘ | ✘ | Unique identifier for the Tile, in the Stack. This is an object containing a "$id" property, which will expose the ID as a 24-byte string | |
sta_feed_id | string |
✔ | ✘ | Globally unique ID to be used for this post (often referencing external ID) | |
guid | string |
✔ | ✘ | Globally unique ID to be used for this post (often referencing external ID) | |
term_id | integer |
✔ | ✘ | Associated term (optional) | |
name | string |
✔ | ✘ | Display name to be used for the author | |
avatar | string |
✔ | ✘ | URL to be used as the post author's avatar | |
title | string |
✔ | ✘ | Tile title to accompany the message, often used for video tiles | |
share_text | string |
✔ | ✘ | Accompanying text to be used when tile is shared on a Social network (e.g. Twitter, Instagram, Facebook, etc.) | |
media | enum | Filter::MEDIA_TEXT Filter:MEDIA_IMAGE Filter::MEDIA_VIDEO Filter::MEDIA_HTML |
✔ | ✘ | The media type of the post | |
video_url | string |
✔ | ✘ | URL of the video file. Required when media type is "video") | |
source_user_id | string |
✔ | ✘ | ||
width_ratio | string |
✔ | ✘ | Tile width ratio to be used as a ratio vs width_ratio as width to height. Positive numeric value. Required when media type is "html" | |
height_ratio | string |
✔ | ✘ | Tile width ratio to be used as a ratio vs height_ratio as width to height. Positive numeric value. Required when media type is "html" | |
image | string |
✔ | ✘ | Full-sized image URL | |
image_url | string |
✔ | ✘ | Full-sized image URL | |
image_small_url | string |
✔ | ✘ | Small image URL (ideally under to 300x300px, or 600x600px for retina) | |
image_medium_url | string |
✔ | ✘ | Medium image URL (ideally under to 600x600px, or 1200x1200px for retina) | |
image_large_url | string |
✔ | ✘ | Large image URL | |
image_width | integer |
✔ | ✘ | ||
image_height | integer |
✔ | ✘ | ||
image_small_width | integer |
✔ | ✘ | ||
image_small_height | integer |
✔ | ✘ | ||
image_medium_width | integer |
✔ | ✘ | ||
image_medium_height | integer |
✔ | ✘ | ||
image_large_width | integer |
✔ | ✘ | ||
image_large_height | integer |
✔ | ✘ | ||
message | string | Tile::STATUS_ENABLED Tile::STATUS_QUEUE Tile::STATUS_DISABLED |
✔ | ✔ | Message body, normalised from the content source. Will be the Tweet text, Facebook status, Instagram caption, etc. Maximum 32k characters | |
original_url | string |
Source content url | |||
html | string |
✔ | ✔ | HTML body, up to 32k characters. This field is mandatory for "html" media type | |
tags | Tag[] |
✔ | ✔ | Array of Tag IDs associated with the Tile. Note: May be returned as array of Integers or Strings | |
source | string | Stackla::NETWORK_TWITTER Stackla::NETWORK_FACEBOOK Stackla::NETWORK_INSTAGRAM Stackla::NETWORK_YOUTUBE Stackla::NETWORK_GPLUS Stackla::NETWORK_FLICKR Stackla::NETWORK_PINTEREST Stackla::NETWORK_TUMBLR Stackla::NETWORK_RSS Stackla::NETWORK_ECAL Stackla::NETWORK_STACKLA Stackla::NETWORK_WEIBO |
✘ | ✘ | The source of the post, often a social network. This field is also referred to as "network" in the filter context | |
status | string |
✔ | ✔ | Tile moderation status | |
longitude | string |
✔ | ✔ | GPS longitude co-ordinate for geo-location | |
latitude | string |
✔ | ✔ | GPS latitude co-ordinate for geo-location | |
disabled_reason | string |
✘ | ✘ | The reason for disabling the tile | |
disabled | bool |
✘ | ✘ | Status either the tile is disabled or not | |
claimed | bool |
✘ | ✘ | Status either the tile is claimed or not | |
anonymous | bool |
✘ | ✘ | Tiles that originate from networks that allow anonymous posts (including Stackla) will have this field set to true. Renderers should not show any attributions the creator of this Tile | |
score | integer |
✘ | ✘ | Accumulated score when the tile being voted | |
created_at | StacklaDateTime |
✘ | ✘ | Creation time | |
updated_at | StacklaDateTime |
✘ | ✘ | Updated time | |
source_created_at | StacklaDateTime |
✘ | ✘ | Original source creation time |
Methods
Method | argument | type | default | return |
---|---|---|---|---|
create* | - | - | - | self or false |
update** | $force | bool | false |
self or false | ||
get | $limit $page $options | integer integer array | 25 1 [] |
|||
getById | $id | integer |
- | Tile / it self or false | |
getByGuid | $guid | string |
- | Tile / it self or false | |
getByStaFeedId | $sta_feed_id | string |
- | Tile / it self or false | |
addTag*** | $tag | Tag |
- | Tile / it self | |
deleteTag*** | $tag | Tag |
- | Tile / it self |
Notes
- create method will only create sta_feed network data.
- update method will only update
$status
and$tag
fields for all network and for sta_feed network the update method will able to update$message
,$html
,$longitude
,$latitude
. - addTag and deleteTag will only add/delete tags from the properties, you still need to call update.
Tag
Properties
Property | type | value | Post | Put | Definition |
---|---|---|---|---|---|
id | integer |
✘ | ✘ | Unique identifier for the Tag | |
tag | string |
✔ | ✔ | Name and display title on the Tag | |
slug | string |
✔ | ✔ | Simplified and class-name-fiendly Tag identifier, most often auto-generated. On output this value is often used to set the class | |
custom_slug | bool |
✔ | ✔ | This value specifies if the slug field value is being auto-generated or overwritten by the user. Must be 1 for true or 0 for false | |
type | enum | Tag:TYPE_CONTENT Tag::TYPE_PRODUCT Tag::TYPE_COMPETITION |
✔ | ✔ | Specifies the type of the Tag | |
publicly_visible | enum | Tag::VISIBLE Tag::NOT_VISIBLE |
✔ | ✔ | This value specifies if display renderers should display this Tag in display context | |
target | enum | Tag::TARGET_BLANK Tag::TARGET_SELF Tag::TARGET_PARENT Tag::TARGET_TOP |
✔ | ✔ | When rendered as a link, this will indicate the target attribute for the anchor tag when used with custom_url | |
system_tag | bool |
✘ | ✘ | Indicates whether this Tag is a read-only tag created and managed by the system. Must be 1 for true or 0 for false | |
priority | integer |
✔ | ✔ | Specifies the sequential sort order in which this Tag should be displayed when being rendered for display. Values range from 1 (highest) to 5 (lowest) with 3 being the default | |
custom_url | string |
✔ | ✔ | URL that clicking on the Tag should take the user to. When type is product, this is the URL that the product click-through should be linked to | |
price | string |
✔ | ✔ | User provided price for Tags of type product | |
ext_product_id | string |
✔ | ✔ | User provided reference to external product for Tags of type product. Should be a continous string, best if URL-friendly. When querying for a product by ID, this value can be prefixed with ext: to fetch by it | |
description | string |
✔ | ✔ | User provided description for Tags of type product. Maximum length: 512 characters | |
image_small_url | string |
✔ | ✔ | URL of the small (optimised for 300px x 300px) image PNG/JPG/JPEG/GIF image to be displayed. This should be a HTTPS URL to so that the Stack or widget can be served over HTTPS completely | |
image_small_width | integer |
✔ | ✔ | Width of the small image being used as the image_small_url, in pixels | |
image_small_height | integer |
✔ | ✔ | Height of the small image being used as the image_small_url, in pixels | |
image_medium_url | string |
✔ | ✔ | URL of the medium (optimised for 600px x 600px) image PNG/JPG/JPEG/GIF image to be displayed. This should be a HTTPS URL to so that the Stack or widget can be served over HTTPS completely | |
image_medium_width | integer |
✔ | ✔ | Width of the small image being used as the image_medium_url, in pixels | |
image_medium_height | integer |
✔ | ✔ | Height of the small image being used as the image_medium_url, in pixels | |
created_at | StacklaDateTime |
✘ | ✘ | UTC timestamp of when this Tag was created |
Methods
Method | argument | type | default | return |
---|---|---|---|---|
create | - | - | - | self or false |
update | $force | bool | false |
self or false | ||
get | $limit $page $options | integer integer array | 25 1 [] |
self or false | ||
getById | $id | integer |
- | self or false | |
getByExtProductId | $id | string |
- | self or false | |
delete | - | - | - | self or false |
Widget
Properties
Property | type | value | Post | Put | Definition |
---|---|---|---|---|---|
id | integer |
✘ | ✘ | Unique identifier for the Tag | |
name | string |
✔ | ✔ | Name and display title on the Tag | |
type | enum | Widget::TYPE_FLUID Widget::TYPE_STATIC |
✔ | ✘ | Specifies the type of the Tag | |
type_style | enum | Widget::STYLE_VERTICAL_FLUID (for fluid only) Widget::STYLE_HORIZONTAL_FLUID (for fluid only) Widget::STYLE_CAROUSEL Widget::STYLE_SCROLL Widget::STYLE_SLIDESHOW Widget::STYLE_AUTO |
✔ | ✔ | This value is depend on the type. | |
filter_id | integer |
✔ | ✔ | default filter for the widget | |
parent_id | integer |
✘ | ✘ | This field will be filled using source filter_id if the widget is derived from other widget | |
embed_code | string |
✘ | ✘ | The embed code (html) for website |
Methods
Method | argument | type | default | return |
---|---|---|---|---|
create | - | - | - | self or false |
update | $force | bool | false |
self or false | ||
get | $limit $page $options | integer integer array | 25 1 [] |
Term objects / self or false | ||
getById | $id | integer |
- | widget object / self or false | |
duplicate* | - | - | - | this method will clone current loaded widget. return false if failed or widget object if success |
derive** | $filter_id $name | integer string |
- - |
This method will inherit current loaded widget to new widget with provided filter id and name. return false if failed or widget object if success | |
delete*** | - | - | - | widget object / self or false |
Notes
- clone or duplicate will copy all CSS and JavaScript from the source.
- derive widget cannot be changed. The only fields that can be changed are
$filter_id
and$name
. - delete will not work if the widget has child widget.
Error Handling
All versions of stackla-php-sdk with dependencies
symfony/validator Version 2 - 3
doctrine/annotations Version ~1.2
doctrine/cache Version ~1
php Version >=5.4