Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
problem creating a simple Request Curl object
  • I'm trying to do an API call to twitter and followed the documentation at http://fuelphp.com/docs/classes/request/curl.html but can't seem to get the ball rolling.  (Keep getting the Bloody Hell page).

    Here is my quick and dirty test code (with the set_params and set_header info omitted.)

    $curl = Request::forge('https://api.twitter.com/1.1/search/tweets.json', 'curl');
    $curl->set_method('get');
    $curl->execute();
    $result = $curl->response();
    print_r ($result);

    I realize this won't authenticate but I'm expecting this back from twitter at least.  Anyone got any ideas?  (or a link to an simple working example using the Request/Curl class?  Thanks 
    {
    • errors
      [
      • {
        • message"Bad Authentication data",
        • code215
        }
      ]
    }


  • You get that because twitter responds with an HTTP STATUS 400, and the curl driver sees that as a NOT FOUND. So you need to catch that to avoid the framework taking over.

    try
    {
        $curl = Request::forge('https://api.twitter.com/1.1/search/tweets.json', 'curl');
        $curl->set_method('get');
        $curl->execute();
    }
    catch (\HttpNotFoundException $e)
    {
        $result = $curl->response();
        print_r ($result);
    }

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion