Skip to main content
added 933 characters in body
Source Link
Mark Henderson
  • 3.4k
  • 2
  • 18
  • 20

This is probably a dumb question, but: How do you retrieve the body of a post?

For example, I have:

$questionList = $api->Questions()->SortByActivity()->Exec();
while($question = $questionList->Fetch(TRUE)){
      ...
}

But... how do I get the question body? It doesn't seem to be in the API reponse that I can see. I remember in the v1 API you had to explicitly request that the API include the question body. Do you have to do the same thing here somehow?


OK I've now two different filters on the same page for two different requests. A contrived example:

    $qstFilter = new Filter();
    $qstFilter->SetIncludeItems(array('question.body'));
    $qstFilter->SetUnsafe(FALSE);

    $ansFilter = new Filter();
    $ansFilter->SetIncludeItems(array('answer.body'));
    $ansFilter->SetUnsafe(FALSE);

    $questionObj = $api->Questions($qstID); 
    $question = $questionObj->Filter($qstFilter->GetID())->Exec()->Fetch();
    $answers = $questionObj->Answers()->Filter($ansFilter->GetID())->SortByVotes()->Exec();

However, when I am using the FileSystem cache (I have not tried the SQL Cache) I seem to be able to only use one filter at a time - both of the filters show exactly the same content (whichever one is set last).

Commenting out

API::SetCache(new FilestoreCache('stackcache'));

fixes this. So I've just turned the cache off for now.

This is probably a dumb question, but: How do you retrieve the body of a post?

For example, I have:

$questionList = $api->Questions()->SortByActivity()->Exec();
while($question = $questionList->Fetch(TRUE)){
      ...
}

But... how do I get the question body? It doesn't seem to be in the API reponse that I can see. I remember in the v1 API you had to explicitly request that the API include the question body. Do you have to do the same thing here somehow?

This is probably a dumb question, but: How do you retrieve the body of a post?

For example, I have:

$questionList = $api->Questions()->SortByActivity()->Exec();
while($question = $questionList->Fetch(TRUE)){
      ...
}

But... how do I get the question body? It doesn't seem to be in the API reponse that I can see. I remember in the v1 API you had to explicitly request that the API include the question body. Do you have to do the same thing here somehow?


OK I've now two different filters on the same page for two different requests. A contrived example:

    $qstFilter = new Filter();
    $qstFilter->SetIncludeItems(array('question.body'));
    $qstFilter->SetUnsafe(FALSE);

    $ansFilter = new Filter();
    $ansFilter->SetIncludeItems(array('answer.body'));
    $ansFilter->SetUnsafe(FALSE);

    $questionObj = $api->Questions($qstID); 
    $question = $questionObj->Filter($qstFilter->GetID())->Exec()->Fetch();
    $answers = $questionObj->Answers()->Filter($ansFilter->GetID())->SortByVotes()->Exec();

However, when I am using the FileSystem cache (I have not tried the SQL Cache) I seem to be able to only use one filter at a time - both of the filters show exactly the same content (whichever one is set last).

Commenting out

API::SetCache(new FilestoreCache('stackcache'));

fixes this. So I've just turned the cache off for now.

Source Link
Mark Henderson
  • 3.4k
  • 2
  • 18
  • 20

This is probably a dumb question, but: How do you retrieve the body of a post?

For example, I have:

$questionList = $api->Questions()->SortByActivity()->Exec();
while($question = $questionList->Fetch(TRUE)){
      ...
}

But... how do I get the question body? It doesn't seem to be in the API reponse that I can see. I remember in the v1 API you had to explicitly request that the API include the question body. Do you have to do the same thing here somehow?