Plugin Directory

Changeset 629956


Ignore:
Timestamp:
11/26/2012 04:50:24 AM (13 years ago)
Author:
chen420
Message:

TinyWebDB API v 0.2.0, add apiKey and try storeavalue.

Location:
tinywebdb-api/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • tinywebdb-api/trunk/menus.php

    r628574 r629956  
    1212    if ($_POST['issubmitted'] == 'yes') {
    1313        $post_urltrigger = $_POST['urltrigger'];
     14        $post_apikey = $_POST['apikey'];
    1415        $post_tagtype = $_POST['tagtype'];
    1516        update_option("wp_tinywebdb_api_url_trigger", $post_urltrigger);
     17        update_option("wp_tinywebdb_api_key", $post_apikey);
    1618        update_option("wp_tinywebdb_api_tag_type", $post_tagtype);
    1719    }
    1820    $setting_url_trigger = get_option("wp_tinywebdb_api_url_trigger") or $setting_url_trigger = 'api';
    1921    $setting_tagtype = get_option("wp_tinywebdb_api_tag_type") or $setting_tagtype = 'id';
     22    $setting_apikey = get_option("wp_tinywebdb_api_key");
    2023
    2124    echo '<form method="post" action="http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . '">';
     
    4346                  <tr class="active">
    4447            <th class="check-column" scope="row">
    45               <input type="checkbox" name="controllers[]" value="core" />
    4648            </th>
    4749            <td class="plugin-title">
    4850              <strong>Core</strong>
    49               <div class="row-actions-visible">
    50                 <a href="options-general.php?page=json-api&amp;action=deactivate&amp;controller=core&amp;_wpnonce=0e3d72a68d" title="Deactivate this controller" class="edit">’âŽ~</a>            </td>
     51            </td>
    5152            <td class="desc">
    5253              <p>Basic introspection methods</p>
    53 
     54          <p><code><a href="<?php echo get_option('home') . "/" . $setting_url_trigger ?>/info/">info</a></code></p>
    5455            </td>
    5556          </tr>
     57                  <tr class="active">
     58            <th class="check-column" scope="row">
     59            </th>
     60            <td class="plugin-title">
     61              <strong>Get Value</strong>
     62            </td>
     63            <td class="desc">
     64              <p>Get dara from your post by Post ID or  Slug </p>
     65          <p><code><a href="<?php echo get_option('home') . "/" . $setting_url_trigger ?>/getvalue/">getvalue</a></code></p>
     66            </td>
     67          </tr>
     68          </tr>
     69                  <tr class="inactive">
     70            <th class="check-column" scope="row">
     71            </th>
     72            <td class="plugin-title">
     73              <strong>Store A Value</strong>
     74            </td>
     75            <td class="desc">
     76              <p>Store data on a your post by Post ID or  Slug </p>
     77          <p><code><a href="<?php echo get_option('home') . "/" . $setting_url_trigger ?>/storeavalue/">storeavalue</a></code></p>
     78            </td>
    5679     </tbody>
     80    </table>
     81      <div class="clear"></div>
     82    </div>
    5783             
    5884    <h3>Address</h3>
    5985
    60     <tr valign="top">
    61         <th scope="row">URL Trigger</th>
    62         <td><input name="urltrigger" type="text" id="urltrigger" value="<?php echo $setting_url_trigger; ?>" size="50" /><br/>Change the <em>api</em> part of your TinyWebDB APIs to something else. Enter without slashes.</td>
     86    <table class="form-table">
     87        <tr valign="top">
     88            <th scope="row">API base</th>
     89        <td><input name="urltrigger" type="text" id="urltrigger" value="<?php echo $setting_url_trigger; ?>" size="50" /><br/>Specify a base URL for TinyWebDB API. For example, using api as your API base URL would enable the following <?php echo get_option('home'); ?>/api/. You can change the <em>api</em> part of your TinyWebDB APIs to something else. Enter without slashes.</td>
     90    </tr>
     91
     92        <tr valign="top">
     93            <th scope="row">API Key</th>
     94        <td><input name="apikey" type="text" id="apikey" value="<?php echo $setting_apikey; ?>" size="50" /><br/>Set api key to protect your TinyWebDB API. Client mast set same api key to Store A Value to your site</td>
    6395    </tr>
    6496
  • tinywebdb-api/trunk/readme.txt

    r624048 r629956  
    77Requires at least: 3.4
    88Tested up to: 3.4.2
    9 Stable tag: 0.1.3
     9Stable tag: 0.2.0
    1010License: GPLv2 or later
    1111License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    36361. FTP the entire tinywebdb-api directory to your Wordpress blog's plugins folder (/wp-content/plugins/).
    37372. Activate the plugin on the "Plugins" tab of the administration panel.
    38 3. Refer to the usage section of this guide.
     383. Check test URL on admin menu to make sure API work properly.
     394. Refer to Plugin URI to get sample Android test app which make by App Inventor, to create your own app.
    3940
    4041for how to use AppInventor to inventor your Android app with this plugin , visit Plugin URI for detail please.
     
    7475
    7576= 0.2.0 =
     77Release which implemented Get Value Action with API Key.
     78Add test URL on admin menu.
    7679
    7780= 1.0.0 =
  • tinywebdb-api/trunk/tinywebdb-api.php

    r626835 r629956  
    99Author: Hong Chen
    1010Author URI: http://digilib.net/
    11 Version: 0.1.3
     11Version: 0.2.0
    1212*/
    1313
    1414
    1515define("TINYWEBDB", "tools.php?page=tinywebdb-api/tinywebdb-api.php");
    16 define("TINYWEBDB_VER", "0.1.3");
     16define("TINYWEBDB_VER", "0.2.0");
    1717
    1818
     
    131131                exit; // this stops WordPress entirely
    132132                break;
    133 //          case "storeavalue": // this action will enable from v 0.2.x
     133            case "storeavalue": // this action will enable from v 0.2.x
    134134                // JSON_API , Post Parameters : tag,value
    135135                $tagName = get_query_var('tag');
    136                 $tagValue = get_query_var('value');
    137 error_log("Wp TinyWebDB API : storeavalue: " . __FILE__ . "/" . __LINE__ . " $tagName -- $tagValue");
    138                 // Create post object
    139                 $args = array(
    140                   'post_title'    => wp_strip_all_tags( $tagName ),
    141                   'post_content'  => $tagValue,
    142                   'post_status'   => 'publish',
    143                 );
    144 
    145                 // Insert the post into the database
    146                 $postid = wp_insert_post( $args );
    147                 if ($postid == 0) {
    148                     $postid = wp_tinywebdb_api_get_postid($tagName);
     136                $tagValue = get_query_var('value');              // $_REQUEST['value']; //
     137                $apiKey = get_query_var('apikey');
     138error_log("Wp TinyWebDB API : storeavalue: " . __FILE__ . "/" . __LINE__ . " ($apiKey) $tagName -- $tagValue");
     139                $setting_apikey = get_option("wp_tinywebdb_api_key");
     140                if ($apiKey == $setting_apikey){
     141                   
     142                    // Create post object
    149143                    $args = array(
    150                       'ID'           => wp_strip_all_tags( $postid ),
    151                       'post_content' => $tagValue,
     144                      'post_title'    => wp_strip_all_tags( $tagName ),
     145                      'post_content'  => $tagValue,
     146                      'post_status'   => 'publish',
    152147                    );
    153                     $postid = wp_update_post( $args );
     148
     149                    // Insert the post into the database
     150                    $postid = wp_insert_post( $args );
     151                    if ($postid == 0) {
     152                        $postid = wp_tinywebdb_api_get_postid($tagName);
     153                        $args = array(
     154                          'ID'           => wp_strip_all_tags( $postid ),
     155                          'post_content' => $tagValue,
     156                        );
     157                        $postid = wp_update_post( $args );
     158                    }
     159                    $tagName = wp_tinywebdb_api_get_tagName($postid);
     160
     161                    header('Cache-Control: no-cache, must-revalidate');
     162                    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     163                    header('Content-type: application/json');
     164                    echo json_encode(array("STORED", $tagName, $tagValue));
     165                } else {
     166                    echo "check api key.";
    154167                }
    155                 $tagName = wp_tinywebdb_api_get_tagName($postid);
    156 
    157                 header('Cache-Control: no-cache, must-revalidate');
    158                 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    159                 header('Content-type: application/json');
    160                 echo json_encode(array("STORED", $tagName, $tagValue));
    161168                exit;
    162169                break;
Note: See TracChangeset for help on using the changeset viewer.