Announcement

Collapse
No announcement yet.

Recommendation on creating API Server with Scriptcase

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Recommendation on creating API Server with Scriptcase

    Would like to request some pointers on creating an API server with Scriptcase that can be called from a Wordpress site and returns content?

    What is the recommended type of application for the API? What standards are recommended for such a type of Web API development?

  • nnara530
    replied
    Here is an example if that helps

    1) I have created a blank application
    2) created a php function and called this function from OnExecute event

    The following is the content of the php function under Programming PHP methods

    header('Access-Control-Allow-Origin: *');
    header('Content-Type: application/json');

    $data_arr = array();
    $data_arr['data'] = array();

    $check_sql = 'SELECT categoryid, categoryname'
    . ' FROM categories';

    sc_select(rs, $check_sql);

    if (false == {rs})
    {
    echo json_encode(array('message' => 'Error while accessing database.'));
    }
    else
    {
    while(!$rs->EOF)
    {
    $id = $rs->fields[0];
    $categoryname = $rs->fields[1];

    $post_item = array(
    'id' => $id,
    'category' => $categoryname
    );

    array_push ($data_arr['data'], $post_item);

    $rs->MoveNext();
    }
    $rs->Close();
    echo json_encode($data_arr);
    }

    Leave a comment:


  • Giu
    replied
    If yoy just need an API, do it in plain PHP. SC don't offers you anything if you will not use the UI.
    If you still want to use SC. Blank app is the way to go

    Leave a comment:


  • bengrech
    replied
    Thanks for the pointer Albert.

    Leave a comment:


  • aducom
    replied
    Originally posted by bengrech View Post
    Would like to request some pointers on creating an API server with Scriptcase that can be called from a Wordpress site and returns content?

    What is the recommended type of application for the API? What standards are recommended for such a type of Web API development?
    There are two ways to go imho: soap and/or rest interface. For simplicity I would choose a rest interface. You can build those using blank applications, retrieve the url input and respond in xml, json, html etc.

    Leave a comment:

Working...
X