forked from fooleap/disqus-php-api
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
266 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
/** | ||
* 更新评论 | ||
* | ||
* @param id 评论 ID | ||
* @param message 评论内容 | ||
* | ||
* @author fooleap <fooleap@gmail.com> | ||
* @version 2017-08-01 06:10:46 | ||
* @link https://github.com/fooleap/disqus-php-api | ||
* | ||
*/ | ||
namespace Emojione; | ||
date_default_timezone_set('UTC'); | ||
require_once('init.php'); | ||
|
||
$fields_data = array( | ||
'api_key' => DISQUS_PUBKEY, | ||
'post' => $_POST['id'] | ||
); | ||
$curl_url = '/api/3.0/posts/details.json?'.http_build_query($fields_data); | ||
$data = curl_get($curl_url); | ||
$duration = time() - strtotime($data->response->createdAt); | ||
|
||
$output = array(); | ||
|
||
if($data->code !== 0){ | ||
$output = array( | ||
'code' => 2, | ||
'response' => '请求方式有误或不存在此 post' | ||
); | ||
print_r(json_encode($output)); | ||
return; | ||
} | ||
|
||
if( $duration < 1800 ){ | ||
// 三十分钟内 | ||
$post_data = array( | ||
'api_key' => DISQUS_PUBKEY, | ||
'post' => $_POST['id'], | ||
'message' => $_POST['message'] | ||
); | ||
$curl_url = '/api/3.0/posts/update.json'; | ||
$data = curl_post($curl_url, $post_data); | ||
$output = $data -> code == 0 ? array( | ||
'code' => $data -> code, | ||
'response' => post_format($data -> response) | ||
) : $data; | ||
} else { | ||
// 三十分钟外 | ||
$output = array( | ||
'code' => 0, | ||
'response' => '更新失败,留言时间已超过三十分钟' | ||
); | ||
} | ||
|
||
print_r(json_encode($output)); |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.