Commit 50dcac48 authored by Thomas's avatar Thomas
Browse files

Fix cache issue

parent 69f25966
......@@ -42,7 +42,7 @@ class Mastodon_api {
$params["method"] = "POST";
// set access_token
if (isset($this->token['access_token'])) {
$parameters['headers'] = array(
$params['headers'] = array(
'Authorization' => $this->token['token_type'] . ' ' . $this->token['access_token']
);
}
......@@ -62,17 +62,17 @@ class Mastodon_api {
*/
private function _get ($url, $parameters = array()) {
$params["method"] = "POST";
$params["method"] = "GET";
// set authorization bearer
if (isset($this->token['access_token'])) {
$parameters['headers'] = array(
$params['headers'] = array(
'Authorization' => $this->token['token_type'] . ' ' . $this->token['access_token']
);
}
$params['body'] = $parameters;
$url = $this->mastodon_url.$url;
$response = $this->get_content_remote_get($url,$parameters);
$response = $this->get_content_remote_get($url,$params);
return $response;
}
......@@ -80,24 +80,21 @@ class Mastodon_api {
* _patch
*
* @param string $url
* @param array $data
* @param array $parameters
*
* @return array $parameters
*/
private function _patch ($url,$data = array()) {
$parameters = array();
$parameters["PATCH"] = 1;
private function _patch ($url,$parameters = array()) {
// set authorization bearer
if (isset($this->token['access_token'])) {
$parameters['headers'] = array(
'Authorization' => $this->token['token_type'] . ' ' . $this->token['access_token']
);
}
$params["method"] = "PATCH";
if (count($data)) {
$parameters["POST_FIELDS"] = json_encode($data);
}
// set authorization bearer
if (isset($this->token['access_token'])) {
$params['headers'] = array(
'Authorization' => $this->token['token_type'] . ' ' . $this->token['access_token']
);
}
$params['body'] = $parameters;
$url = $this->mastodon_url.$url;
$response = $this->get_content_remote_get($url,$parameters);
......@@ -113,13 +110,14 @@ class Mastodon_api {
*/
private function _delete ($url) {
$parameters = array();
$parameters["DELETE"] = 1;
$parameters["method"] = "DELETE";
// set authorization bearer
if (isset($this->token['access_token'])) {
$authorization = 'Authorization: '.$this->token['token_type'].' '.$this->token['access_token'];
$parameters["HTTP_HEADER"] = array('Content-Type: application/json',$authorization);
}
// set authorization bearer
if (isset($this->token['access_token'])) {
$parameters['headers'] = array(
'Authorization' => $this->token['token_type'] . ' ' . $this->token['access_token']
);
}
$url = $this->mastodon_url.$url;
$response = $this->get_content_remote_get($url,$parameters);
......@@ -746,6 +744,7 @@ class Mastodon_api {
*/
public function search ($parameters) {
$response = $this->_get('/api/v1/search',$parameters);
return $response;
}
......
......@@ -36,7 +36,7 @@
{
'action': 'mastodon_comments_getcomment',
'post_id': params.post_id,
'search': "https://mastalab.app/2018/09/02/how-to-login/",
'search': window.location.href,
'mastodon_comments_nonce': params.mastodon_comments_nonce
},
function(data){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment