Skip to main content
deleted 75 characters in body
Source Link
rene
  • 2.8k
  • 2
  • 17
  • 35

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

<?php
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 'stackoverflow.com' here.

$question = new QuestionRequest('http://www.stackoverflow.com', null);
$question = $question->Search("C#");

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

?>


<html>
    <head>
        <?php
            include("includes/bootstrap.php");
        ?>
        
          <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' /> -->

    </head>
    <body>
        <?php include("includes/banner.php"); ?>
        
        <div class="main_content">
              <h2>Questions Asked By User #1 on Stack Overflow</h2>
              
              <?php echo $page->Fetch(); ?>
        </div>


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

I keep getting the error

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

Any thoughts

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

thank you this worked.

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

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

<?php
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 'stackoverflow.com' here.

$question = new QuestionRequest('http://www.stackoverflow.com', null);
$question = $question->Search("C#");

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

?>


<html>
    <head>
        <?php
            include("includes/bootstrap.php");
        ?>
        
          <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' /> -->

    </head>
    <body>
        <?php include("includes/banner.php"); ?>
        
        <div class="main_content">
              <h2>Questions Asked By User #1 on Stack Overflow</h2>
              
              <?php echo $page->Fetch(); ?>
        </div>


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

I keep getting the error

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

Any thoughts

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

thank you this worked.

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

<?php
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 'stackoverflow.com' here.

$question = new QuestionRequest('http://www.stackoverflow.com', null);
$question = $question->Search("C#");

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

?>


<html>
    <head>
        <?php
            include("includes/bootstrap.php");
        ?>
        
          <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' /> -->

    </head>
    <body>
        <?php include("includes/banner.php"); ?>
        
        <div class="main_content">
              <h2>Questions Asked By User #1 on Stack Overflow</h2>
              
              <?php echo $page->Fetch(); ?>
        </div>


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

I keep getting the error

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

deleted 1575 characters in body
Source Link
austin
  • 171
  • 3

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

I have updated to the latest stackphp, but my code has stoped working. I return a total of -1 and cannot call Fetch() without an error

require_once '../stackphp/src/api.php'; // require_once '../stackphp/src/answer_request.php'; // require_once '../stackphp/src/url.php'; // require_once '../stackphp/src/sql_cache.php'; include("../includes/functionthank you this worked.php");

// API::SetCache(new SQLCache(SQLCache::SQLiteMemory));

$query = $_POST['query'];

$site = API::Site('stackoverflow');
// $question = $site->Questions();
// $question->Search($query)->SortByVotes();
// $question->Answers();

//trying to get this working again
$question = $site->Search('C#');



$answers = $question->Exec();


while(isset ($answers) && $q = $answers->Fetch()) {
                            $questionbody = $site->Questions($q['question_id'])->IncludeBody()->Exec();
                            $qb = $questionbody->Fetch();

                            if ( array_key_exists('accepted_answer_id', $q) ) {
                                $ans = $site->Answers($q['accepted_answer_id'])->IncludeBody()->Exec(); 
                                echo "<h3>" . $q['title'] . "</h3>";
                                echo "<div class='answer'>";
                                $a = $ans->Fetch();
                                if ($a != false) {
                                    echo "<div>";
                                        echo "<h2 class='question_head'>{$question_message}</h2>";
                                        echo "<div class='question'> <p> " . $qb['body'] . " </p></div>";
                                        echo "<p>" . $a['body']  . "</p>";
                                    echo "</div>";
                                }
                                echo "</div>";
                            }
                        }

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

I have updated to the latest stackphp, but my code has stoped working. I return a total of -1 and cannot call Fetch() without an error

require_once '../stackphp/src/api.php'; // require_once '../stackphp/src/answer_request.php'; // require_once '../stackphp/src/url.php'; // require_once '../stackphp/src/sql_cache.php'; include("../includes/function.php");

// API::SetCache(new SQLCache(SQLCache::SQLiteMemory));

$query = $_POST['query'];

$site = API::Site('stackoverflow');
// $question = $site->Questions();
// $question->Search($query)->SortByVotes();
// $question->Answers();

//trying to get this working again
$question = $site->Search('C#');



$answers = $question->Exec();


while(isset ($answers) && $q = $answers->Fetch()) {
                            $questionbody = $site->Questions($q['question_id'])->IncludeBody()->Exec();
                            $qb = $questionbody->Fetch();

                            if ( array_key_exists('accepted_answer_id', $q) ) {
                                $ans = $site->Answers($q['accepted_answer_id'])->IncludeBody()->Exec(); 
                                echo "<h3>" . $q['title'] . "</h3>";
                                echo "<div class='answer'>";
                                $a = $ans->Fetch();
                                if ($a != false) {
                                    echo "<div>";
                                        echo "<h2 class='question_head'>{$question_message}</h2>";
                                        echo "<div class='question'> <p> " . $qb['body'] . " </p></div>";
                                        echo "<p>" . $a['body']  . "</p>";
                                    echo "</div>";
                                }
                                echo "</div>";
                            }
                        }

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

thank you this worked.

added 1638 characters in body
Source Link
austin
  • 171
  • 3

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

I have updated to the latest stackphp, but my code has stoped working. I return a total of -1 and cannot call Fetch() without an error

require_once '../stackphp/src/api.php'; // require_once '../stackphp/src/answer_request.php'; // require_once '../stackphp/src/url.php'; // require_once '../stackphp/src/sql_cache.php'; include("../includes/function.php");

// API::SetCache(new SQLCache(SQLCache::SQLiteMemory));

$query = $_POST['query'];

$site = API::Site('stackoverflow');
// $question = $site->Questions();
// $question->Search($query)->SortByVotes();
// $question->Answers();

//trying to get this working again
$question = $site->Search('C#');



$answers = $question->Exec();


while(isset ($answers) && $q = $answers->Fetch()) {
                            $questionbody = $site->Questions($q['question_id'])->IncludeBody()->Exec();
                            $qb = $questionbody->Fetch();

                            if ( array_key_exists('accepted_answer_id', $q) ) {
                                $ans = $site->Answers($q['accepted_answer_id'])->IncludeBody()->Exec(); 
                                echo "<h3>" . $q['title'] . "</h3>";
                                echo "<div class='answer'>";
                                $a = $ans->Fetch();
                                if ($a != false) {
                                    echo "<div>";
                                        echo "<h2 class='question_head'>{$question_message}</h2>";
                                        echo "<div class='question'> <p> " . $qb['body'] . " </p></div>";
                                        echo "<p>" . $a['body']  . "</p>";
                                    echo "</div>";
                                }
                                echo "</div>";
                            }
                        }

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

I have updated to the latest stackphp, but my code has stoped working. I return a total of -1 and cannot call Fetch() without an error

require_once '../stackphp/src/api.php'; // require_once '../stackphp/src/answer_request.php'; // require_once '../stackphp/src/url.php'; // require_once '../stackphp/src/sql_cache.php'; include("../includes/function.php");

// API::SetCache(new SQLCache(SQLCache::SQLiteMemory));

$query = $_POST['query'];

$site = API::Site('stackoverflow');
// $question = $site->Questions();
// $question->Search($query)->SortByVotes();
// $question->Answers();

//trying to get this working again
$question = $site->Search('C#');



$answers = $question->Exec();


while(isset ($answers) && $q = $answers->Fetch()) {
                            $questionbody = $site->Questions($q['question_id'])->IncludeBody()->Exec();
                            $qb = $questionbody->Fetch();

                            if ( array_key_exists('accepted_answer_id', $q) ) {
                                $ans = $site->Answers($q['accepted_answer_id'])->IncludeBody()->Exec(); 
                                echo "<h3>" . $q['title'] . "</h3>";
                                echo "<div class='answer'>";
                                $a = $ans->Fetch();
                                if ($a != false) {
                                    echo "<div>";
                                        echo "<h2 class='question_head'>{$question_message}</h2>";
                                        echo "<div class='question'> <p> " . $qb['body'] . " </p></div>";
                                        echo "<p>" . $a['body']  . "</p>";
                                    echo "</div>";
                                }
                                echo "</div>";
                            }
                        }
Source Link
austin
  • 171
  • 3
Loading