Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to query stackoverflow and route it to my website via the following

require_once './stackphp_source_0.4/src/api.php';
require_once './includes/function.php';

// Begin by getting a Site object for Stack Overflow.
// We can use 'stackoverflow' or '' here.

$question = new QuestionRequest('', null);
$question = $question->Search("C#");

// paged Response object
$page = $question->Answers()->Exec(); 



          <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <title>Stack.PHP - User's Questions</title>
  <!-- <link rel='stylesheet' type='text/css' href='../common/style.css' /> -->

        <?php include("includes/banner.php"); ?>

        <div class="main_content">
              <h2>Questions Asked By User #1 on Stack Overflow</h2>

              <?php echo $page->Fetch(); ?>

    <?php include("includes/script_includes.php"); ?>

I keep getting the error

Curl was unable to retrieve the data from the specified URL.

Any thoughts

EDIT ----------------------

thank you this worked.

share|improve this question
up vote 1 down vote accepted

First of all, you should be using the latest version of Stack.PHP, which is version 0.5. You can download a tarball here:

The only file you need to include is api.php which is in the src/ directory.

You will almost never need to create a Request object yourself since you can obtain it from a Site object. You can do that with:

$site = API::Site('stackoverflow');

Now you can use $site to access the methods available on that site, most of which return a subclass of Request:

$request = $site->Search('C#');

Once you have a request, you need to convert it into a response. This is done as follows:

$response = $request.exec();

You can then enumerate the items in the response with:

while($q = $response->Fetch(FALSE))
    // do something with $q here

For example, echo $q['title'] will display the question's title.

share|improve this answer
I have updated my question, still having issues with this – austin Nov 16 '13 at 18:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .