2009/1/5 Pete Wingard <petew...@gmail.com>:
> I have this cURL
> function get_tweets(){
> // create a new cURL resource
> $ch = curl_init();
> $user = "netlatch";
> $pass = "************";
> // set URL and other appropriate options
> // $user:$pass http://twitter.com/statuses/replies.json
> curl_setopt($ch, CURLOPT_USERPWD, $user.":".$pass);
> curl_setopt($ch, CURLOPT_URL,
> "http://twitter.com/users/show/netlatch.json");
> curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,2);
> // grab URL and pass it to the browser
> $input = curl_exec($ch);
var_dump($input);
> $val = json_decode($input);
var_dump($val);
> $output = $val->{"text"};
var_dump($output);
> // close cURL resource, and free up system resources
> curl_close($ch);
> return $output;
> }
> $array=get_tweets();
> but I get nothing in the $array. It dumps the content on the page though. If
> I use this w/o a username and password I get an error of too many requests.
> What am I doing wrong?
You're not doing basic legwork before asking for help. However, I'm
gonna throw you a bone. Read up on the CURLOPT_RETURNTRANSFER option -
that's what you're missing.
-Stuart
Once you get the xml/json thing figured out, you might want to look
into the PHP functions:
imagecreatefromjpeg
imagecreatefrompng
imagecreatefromgif
http://us2.php.net/manual/en/function.imagecreatefromjpeg.php
to help you save the images locally... I've done this before to store
user avatars on my server.
-Chad
$host = "http://twitter.com/users/show/$businessUser.xml";
You need to set
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
or $input will contain the curl result code, not the page contents.
-Matt
You need to set
I apologise if I got the tone of my email wrong, but your problem
indicates to me that you haven't really read the documentation for the
curl extension in the PHP manual. I have no problem helping people who
have done the basics... 1) read the manual, 2) have a go, and 3) apply
basic debugging skills if it doesn't work.
You've demonstrated 2, great, but I saw little to no evidence of 1 and 3.
In response to Chad's email I take the view that fishing is always a
better option than going to a fish market where coding is concerned.
-Stuart
True, and I agree... but sometimes you must go to the fish market
first in order to learn that you should really buy a fishing pole
instead.
In any event, I am grateful that there really isn't a lot of total
n00bage on this list (like on so many other lists). I did not mean to
offend either... just didn't want to Pete to get discouraged since
what he is trying to do is entirely possible.
-Chad