Skip to content

WRONG_SIGNATURE When try to delete article #20

Open

Description

@nemanja947

When i try to delete an article i get this error:
PHP Notice: Array
(
[code] => 401
[message] => HTTP/1.1 401 Unauthorized
[response] => stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[code] => WRONG_SIGNATURE
)
)
)
)

What's weird is that before I delete it, I get the news over Get method, this is my code:

if ($item['AppleArticle']['status'] == 'deleted') {
$response_get = $PublisherAPI->Get('/articles/{article_id}',
array(
'article_id' => $item['AppleArticle']['appleId']
)
);
if (isset($response_get->data->id)) {

                    $response_delete = $PublisherAPI->Delete('/articles/{article_id}',
                        array(
                            'article_id' => $response_get->data->id
                        )
                    );

Activity

  1. nguyentamgm commented on Oct 30, 2018

    @nguyentamgm

    Same problem here, GET and POST are ok, DELETE doesn't work

  2. nguyentamgm commented on Oct 30, 2018

    @nguyentamgm

    I updated Curl/Curl.php and it is now working

        public function delete($url, $query_parameters = array(), $data = array())
        {
            if (is_array($url)) {
                $data = $query_parameters;
                $query_parameters = $url;
                $url = (string)$this->url;
            }
    
            $this->setUrl($url, $query_parameters);
            $this->setOpt(CURLOPT_CUSTOMREQUEST, 'DELETE');
    // Start editing
            if (!empty($data)) {
                $this->setOpt(CURLOPT_POSTFIELDS, $this->buildPostData($data));
            }
    // End editing
            return $this->exec();
        }
    

    The reason is Apple News needs another type of signature when using POST data, and it seems to be like Apple News uses CURLOPT_POSTFIELDS from header to determine a POST action! 🤪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions