我是codeigniter的新手。我可以轻松地使用像这样的核心php上的parse.com库
<?php
// define location of Parse PHP SDK, e.g. location in "Parse" folder
// Defaults to ./Parse/ folder. Add trailing slash
define( 'PARSE_SDK_DIR', '../src/Parse/' );
// include Parse SDK autoloader
require_once( 'autoload.php' );
// Add the "use" declarations where you'll be using the classes
use Parse\ParseClient;
use Parse\ParseObject;
use Parse\ParseQuery;
use Parse\ParseACL;
use Parse\ParsePush;
use Parse\ParseUser;
use Parse\ParseInstallation;
use Parse\ParseException;
use Parse\ParseAnalytics;
use Parse\ParseFile;
use Parse\ParseCloud;
// Init parse: app_id, rest_key, master_key
ParseClient::initialize('id', 'id2', 'id3');
// save something to class TestObject
$testObject = ParseObject::create("TestObject");
$testObject->set("foo", "bar");
$testObject->save();
// get the object ID
echo $testObject->getObjectId();
echo '<h1>Users</h1>';
// get the first 10 users from built-in User class
$query = new ParseQuery("_User");
$query->limit(10);
$results = $query->find();
foreach ( $results as $result ) {
// echo user Usernames
echo $result->get('username') . '<br/>';
}
但我无法在codeigniter中使用它。请帮助我如何在codeigniter中添加parse.com并使用它。 请给我一些方向和示例
答案 0 :(得分:0)
从这里下载CI库 parse.com将所有代码粘贴到您的应用程序/库文件夹中。确保您已创建自定义配置parse.php文件示例
<?php
/**
* Parse keys
*/
$config['parse_appid'] = '';
$config['parse_masterkey'] = '';
$config['parse_restkey'] = '';
$config['parse_parseurl'] = 'https://api.parse.com/1/';
?>
并在您的样本控制器ParseSample.php中尝试此操作。
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class ParseSample extends CI_Controller {
public function index()
{
$temp = $this->load->library('parse');
$testObj = $this->parse->ParseObject('testObj');
$testObj->data = array("testcol" => "it works");
$return = $testObj->save($testObj->data);
echo "<pre>";
print_r($return);
echo "<pre>";
var_dump($return);
exit;
}
}
希望有人可能会有所帮助。