Thingdom.io API 的官方 PHP 库

dev-master 2015-02-06 02:19 UTC

This package is not auto-updated.

Last update: 2024-09-28 16:51:45 UTC


README

PHP 库,用于 Thingdom.io API v1.1。

什么是 Thingdom?

Thingdom 允许您用四行代码将产品移动化,无需开发 iOS 和 Android 应用或创建可扩展的云基础设施。 立即开始!

要求

您必须安装 PHP 的 cURL 以使用此库。

CentOS

sudo yum install php5-curl

Ubuntu

sudo apt-get install php5-curl

入门指南

首先,获取免费 API 访问权限。接下来,如果您不使用 composer,请下载此库,然后尝试以下代码。

<?php

require_once('Thingdom.php');

// instantiate Thingdom object and authenticate
$thingdom = new Thingdom('YOUR_API_SECRET');

// look-up Thing and get back object
$thing = $thingdom->getThing('YOUR_THING_NAME');

// send a feed message
$thing->feed('FEED_CATEGORY', 'MESSAGE');

// send a status update
$thing->status('KEY', 'VALUE');

如果您想使用 composer,请按照以下说明操作。

  1. 安装 composer

  2. 创建一个新的 composer.json 文件,将 thingdomio/thingdom-php 作为依赖项(或将它添加到您项目的现有 composer.json 文件中)

     {
         "require": {
             "thingdomio/thingdom-php": "dev-master"
         }
     }
    
  3. 使用 composer 安装依赖项

  4. 然后尝试以下代码。

     <?php
    
     require_once __DIR__ . '/vendor/autoload.php'; // Autoload files using Composer autoload
    
     // instantiate Thingdom object and authenticate
     $thingdom = new Thingdom('YOUR_API_SECRET');
    
     // look-up Thing and get back object
     $thing = $thingdom->getThing('YOUR_THING_NAME');
    
     // send a feed message
     $thing->feed('FEED_CATEGORY', 'MESSAGE');
    
     // send a status update
     $thing->status('KEY', 'VALUE');
    

库使用想法

  1. 通过您的 PHP 代码编程触发推送通知、推送消息和实时状态更新。
  2. 远程监控与您的 PHP 应用程序或 Web 服务器的任何交互。
  3. 通过我们的快速集成和简单的 API 调用,您可以在数小时内将 PHP 应用程序移动化,甚至可以根据您的最终用户定制移动体验。