← Back

ofxSquidexHelper

github.com/local-projects/ofxSquidexHelper · @local-projects
OF 0.11 Web/Networking

Helper addon for interfacing with the Squidex CMS, handling OAuth tokens, JSON requests, and retrieving asset content as ofPixels.

2 0 Last commit 6y ago Created 6y ago

README

ofxSquidexHelper



TODO:



Fix : postSquidexAsset() - unable to post asset to squidex, notes regarding the error can be found in code.

Intro



Helper for Interfacing with Squidex CMS. Current Functionality includes;

Post/ to retrieve oauth token Get/ Basic Request returning JSON Get/ Asset Content Request returning ofPixels Post/ Basic JSON data request with JSON response Post/ Asset Image Request [ WIP ].

A note about Naming re : Content vs. Asset

CONTENT on Squidex is an object with many attributes, one being an ASSET_ID - which links the ASSET to the CONTENT object An ASSET is the actual asset object, including the file and other info Therefore getContent - is getting the content object ( info about the content w/ ref to an asset ) getAssets - is getting the Asset object ( info about the asset ) getAssetContent - is getting the Asset file ( literal asset pixels )

Dependancies :



ofxHTTP ofxPoco ( included w/ OF ) ofxSSLManager ofxIO ofxMediaType ofxNetworkUtils

Usage



SSLManager set-up : Requires Client Certificate is located in bin/data/ssl download latest here https://curl.haxx.se/docs/caextract.html. Additionally one can be found in example/bin/data/ssl

getSquidexToken( string url, string clientID, string clientSecret )

Post request to retrieve oauth token Returns token as string Token is required for any Squidex request to be authenticated Squidex - Authentication

getSquidexContent( string url, string token )

General Get request - can be used for any basic GET/ request that responds with JSON. returns ofJson object

getSquidexAssetContent( string url, string token )

Get Asset Image - Returns an ofPixel Object of the asset ready for usage Asset Id is required as URI param Squidex - Get The Asset Content

postSquidexContent( string url, string token, ofJson data )

General JSON POST request - can be used for any basic POST/ request that sends and recieves a JSON object Refer to ofJson for how to build ofJson data object

[WIP] postSquidexAsset( string url, string token, string localPath, string filename )

Post Asset Image - Posts base_64 encoded Image loaded from file Optional Param for Parent Folder id Returns JSON object with asset information ( including ID )

Example



To run example code;

make sure you have SSL cert in bin/data/ssl This example uses ofxJsonSettings ( ofxJSON dep ) to set credentials for connecting to squidex. Make sure to include a json file with squidex info here bin/data/tmp/settings.json or assign your own values in setup(). Format of json file is as follows;

{ "baseUrl" : "https://cloud.squidex.io", "appName" : "{app-name}", "contentParent" : "{content-bucket}", "clientID" : "{client-id}", "clientSecret" : "{client-secret}" } //contentParent = param that used when making a content call to a specific schema.. /api/content/appName/{contentParent}/

About example code;

hit '1' to generate access token hit '2' to getContent Objects, then Pass them through to getAssetContent to download the images and add to an array to displaying hit '3' to post image to cms, image located in bin/data/uploads file name must be "1_TEST.png" [ this function does not work correctly ] hit '4' to get a random asset from cms and generate a content object for it using a JSON post

Get this addon

HTTPS
SSH