curl with php

27 views
Skip to first unread message

Ryan

unread,
Jul 3, 2010, 8:06:52 PM7/3/10
to PBwiki API Hackers, 2wa...@gmail.com
I'm trying to use cURL via php using the example from user "GotInc"
below to access my pbwiki...

http://groups.google.com/group/pbwiki-api/browse_thread/thread/5503769517ec8df5

Here's the code I'm actually running and the error I'm receiving. I
fear I just need a fresh pair of eyes to take a look.

<pre>
<?php
require_once 'includes/curl.php';
$curl = new Curl;
$url = "https://mysite.pbwiki.com/api_v2/";
$vars = array(
"op" => "GetPage",
"page" => "FirstPage",
"_type" => "jsontext",
"read_key" => "MYSECRETKEY"
);
$response = $curl->post($url, $vars);
print_r($response->headers);
echo $response;
?>
</pre>

Notice: Trying to get property of non-object in /Applications/MAMP/
htdocs/html/test-decode.php on line 12

Thanks in advance for the help.

Walker Whitehouse

unread,
Jul 4, 2010, 12:30:58 AM7/4/10
to Ryan, PBwiki API Hackers
Hi Ryan,

Perhaps the object is empty and thus you get this error.
Try the code below after $response = $curl->post($url, $vars);
It will help to determine if you are making a valid request.

<pre>

    if($response->headers['Status-Code'] !== '200') {
        echo "Invalid status code from Request";
    } else {
        echo $response;
    }

</pre>

Perhaps because you are requesting "FirstPage" when you might have better luck with "FrontPage"

Hope this helps.

-WW
Reply all
Reply to author
Forward
0 new messages