6

I have an id of created article and I also can get the status of the article by GET method:

{article_id}?access_token={access_token}

I get a response like:

{
  "id": {article_id},
  "status": "SUCCESS"
}

But when I try to delete the article by the DELETE method with the same params I'm getting this response:

{
  "error": {
    "message": "(#240) Requires a valid user to be specified (either via the session or via the API parameter for specifying the user.",
    "type": "OAuthException",
    "code": 240,
    "fbtrace_id": "GsXXXXBjq"
  }
}

Everything was done according to the documentation.

I'm using v2.6 graph version whit this permissions:

publish_pages, pages_manage_instant_articles, manage_pages

I use a page token that do not expire, I got it by @Simon.Ponder's answer.

I have the only one admin user for the application and the page.

How can it be solved?

Community
  • 1
  • 1
whitesiroi
  • 2,725
  • 4
  • 30
  • 64
  • What type of token did you use? – CBroe Jun 21 '16 at 11:29
  • @CBroe I use a page token that do not expire. – whitesiroi Jun 21 '16 at 15:55
  • Just curious, it could be that the endpoint was not correctly documented. Try `DELETE /{page-id}/instant_articles/{article-id}`. This [part of the graph api docs](https://developers.facebook.com/docs/graph-api/reference/page/instant_articles/#Deleting) conflicts with the other link you shared – Oluwafemi Sule Jul 11 '16 at 18:36
  • Is it possible you need additional permissions to issue DELETE requests? – TW80000 Jul 11 '16 at 18:47
  • 1
    Are you sure you didn't mix up your `{article-id}` and `{access_token}`? :P – Quirk Jul 12 '16 at 03:58
  • I have similar issue, but the response for me is: [message] => (#200) User cannot access this application . I've created the article with the same user and the same long-lived access token – V.Vachev Aug 25 '16 at 09:27
  • @Quirk Thank you very much for your comment. I was mixing up article_id with ID that I get from Facebook API after posting the article. – whitesiroi Sep 01 '16 at 10:01
  • @whitesiroi You should probably write an answer describing what fixed your issue and accept it. – Quirk Sep 01 '16 at 14:42
  • @Quirk I still haven't solved it:) I'm getting a new error "(#240) Requires a valid user to be specified (either via the session or via the API parameter for specifying the user." – whitesiroi Sep 02 '16 at 02:23

2 Answers2

1

I was able to delete post by using facebook-instant-articles-sdk-php

     $client = Client::create(
                     $this->options->app_id,
                     $this->options->app_secret,
                     $this->options->access_token,
                     $this->options->page_id,
                     true);

     try {
             $client->removeArticle($my_canonical_url)
     } catch (Exception $e) {
             throw $e->getMessage();
     }

Hope it helps someone.

whitesiroi
  • 2,725
  • 4
  • 30
  • 64
1

In your question you are saying after posting your article you are getting response like this

{
  "id": {article_id},
  "status": "SUCCESS"
}

But this is not article_id this is import_status_id. So

{
      "id": {import_status_id},
  "status": "SUCCESS"
}

With import_status_id you can get article_id using this api if your articles is posted successfully. then you can delete your article using delete api as usual. Thanks.

Narasimha Reddy - Geeker
  • 3,510
  • 2
  • 18
  • 23