简体   繁体   English

使用laravel 5.1向Twitter API发出卷曲请求

[英]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 刚开始使用curl对此并不太了解,我正在尝试通过laravel 5.1通过Curl向Twitter API发送请求,这是我的控制器代码

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 我从curl网站下载了一个curl文件夹,并将curl.exe文件放置在D:\\ General软件中,并且还更改了环境变量路径,但是现在它答复了Undefined variable:client

PHP comes with curl extension (look for php_curl.dll file in Windows). PHP带有curl扩展名(在Windows中寻找php_curl.dll文件)。 You just need to add that extension in PHP.ini and then restart web server. 您只需要在PHP.ini中添加该扩展名,然后重新启动Web服务器即可。 This line is what cause undefined error. 这行是导致未定义错误的原因。 $client is not initialized. $client未初始化。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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