简体   繁体   中英

Curl request to twitter API using laravel 5.1

just start using curl don't know much about it i am trying to send a request to twitter API using laravel 5.1 through Curl that's my Controller code

public function getTwitterLogin($auth=NULL){
    if($auth == 'auth')
    {
        Hybrid_Endpoint::process();
        return;
    }
    try{
        $oauth=new Hybrid_Auth(app_path(). '/config/twitterAuth.php');
        $provider=$oauth->authenticate('Twitter');
        $client->getHttpClient()->setDefaultOption('verify', 'D:\General software');
       //curl_init();
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, 'https://api.twitter.com/1.1/users/search.json');
        $result = curl_exec($curl);
          var_dump($result);

i downloaded a curl folder from curl website and place the curl.exe file in D:\\General software and changed the environment variable path also but now its replying that Undefined variable: client

PHP comes with curl extension (look for php_curl.dll file in Windows). You just need to add that extension in PHP.ini and then restart web server. This line is what cause undefined error. $client is not initialized.

$client->getHttpClient()->setDefaultOption('verify', 'D:\General software');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM