本文整理汇总了PHP中Api::put方法的典型用法代码示例。如果您正苦于以下问题:PHP Api::put方法的具体用法?PHP Api::put怎么用?PHP Api::put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Api
的用法示例。
在下文中一共展示了Api::put方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: commit
/**
* Commit batch
*
* @throws \Exception
*/
public function commit()
{
$response = $this->api->put('/v4/batch', ['batch-id' => $this->getBatchId()]);
if (!isset($response['success']) || !$response['success']) {
throw new \Exception("Response was not successful.");
}
$this->isCommitted = true;
}
示例2: create_token
/**
* Creates and returns a new token/api_key combination for the
* specified user ID. Returns an array with the two values. Note
* that for an existing user ID, this will generate a new pair,
* replacing the old values and making them no longer valid for
* API access.
*/
public static function create_token($user_id)
{
$a = self::query()->where('user_id', $user_id)->single();
if ($a && !$a->error) {
$a->token = md5(uniqid(mt_rand(), 1));
$a->api_key = md5(uniqid(mt_rand(), 1));
} else {
$a = new Api(array('token' => md5(uniqid(mt_rand(), 1)), 'api_key' => md5(uniqid(mt_rand(), 1)), 'user_id' => $user_id));
}
while (!$a->put()) {
$a->token = md5(uniqid(mt_rand(), 1));
}
return array($a->token, $a->api_key);
}
示例3: create_token
/**
* Creates and returns a new token/api_key combination for the
* specified user ID. Returns an array with the two values. Note
* that for an existing user ID, this will generate a new pair,
* replacing the old values and making them no longer valid for
* API access.
*/
public static function create_token($user_id)
{
$a = Api::query()->where('user_id', $user_id)->fetch();
if (count($a) > 0) {
$a = $a[0];
$a->token = md5(uniqid(mt_rand(), 1));
$a->api_key = md5(uniqid(mt_rand(), 1));
} else {
$a = new Api(array('token' => md5(uniqid(mt_rand(), 1)), 'api_key' => md5(uniqid(mt_rand(), 1)), 'user_id' => $user_id));
}
while (!$a->put()) {
$a->token = md5(uniqid(mt_rand(), 1));
}
return array($a->token, $a->api_key);
}
示例4: action_view
public function action_view()
{
$id = (int) $this->request->param('id');
$user_id = Auth::get_id();
$message = Api::get('user-messages.get_by_id', array('id' => $id, 'uid' => $user_id, 'fields' => 'author,title,is_read,created_on,text,is_starred'))->as_object();
if (!$message->response) {
throw new HTTP_Exception_404('Message not found');
}
if ($this->request->method() === Request::POST) {
$this->auto_render = FALSE;
$post = $this->request->post();
$post['from_user_id'] = $user_id;
$post['parent_id'] = $id;
return $this->_send(Api::put('user-messages', $post), $id);
}
$read = Api::post('user-messages.mark_read', array('id' => $id, 'uid' => $user_id));
$messages = Api::get('user-messages.get', array('uid' => $user_id, 'fields' => 'author,from_user_id,title,is_read,created_on,text,is_starred', 'pid' => $id))->as_object();
$this->template->content = View::factory('messages/view', array('tpl' => View::factory('messages/item'), 'message' => $message->response, 'messages' => $messages->response, 'from_user' => ORM::factory('user', $message->response->from_user_id)));
$this->set_title($message->response->title);
}
示例5: Api
<?php
require __DIR__ . '/credentials.php';
require __DIR__ . '/../facturama/Api.php';
$facturma = new Api(USER, PASSWORD);
$clientId = 'TGpJ_Ko32_ZSEPBcZXRnRw2';
/*$params = [
'id' => $clientId
];*/
$body = ["Id" => $clientId, "Address" => ["Street" => "St One", "ExteriorNumber" => "15", "InteriorNumber" => "12", "Neighborhood" => "Lower Manhattan, ", "ZipCode" => "sample string 5", "Locality" => "sample string 6", "Municipality" => "sample string 7", "State" => "sample string 8", "Country" => "MX"], "Rfc" => "XEXX010101000", "Name" => "Test Test 2", "Email" => "test@facturma.com"];
//$result = $facturma->put('Client/' . $clientId, $body, $params);
$result = $facturma->put('Client/' . $clientId, $body);
printf('<pre>%s<pre>', var_export($result, true));