Why does it not call https rest API using curl in php?

综合编程 2017-12-31

I am trying to make an API call with this code:

quote->author.'
'; echo $json_objekat->quote->body.'
'; ?>

This code is saved as a php file in www (root) folder on my local machine. I use a WAMP server.

When I open this file from WAMP it says:

Notice:  Trying to get property of non-object in C:wampwwwIzdavackaKucajavniServis.php on line 10 Trying to get property of non-object in C:wampwwwIzdavackaKucajavniServis.php on line 10 Trying to get property of non-object in C:wampwwwIzdavackaKucajavniServis.php on line 11 Trying to get property of non-object in C:wampwwwIzdavackaKucajavniServis.php on line 11

I checked php extensions option php_curl on WAMP and I don't know if I should check some other options. I don't know if there is some problem with my WAMP server or what the problem is, because I have sent this same code to a couple of other people and they say that it works on their computer. I don't know where the error is so I hope someone can help me.

Thank you!

Unless you really otherwise do; i imagine that you may not have a Problem with your WAMP Server. The Problem i found is that the URL https://favqs.com/api/qotd.json has an Unknown SSL Protocol according to the Error Message. Check it out yourself:

 'https://favqs.com/api/qotd.json',
        CURLOPT_POST            => false,
        CURLOPT_HEADER          => false,
        CURLOPT_SSL_VERIFYPEER  => false,
        CURLOPT_RETURNTRANSFER  => true,
        CURLOPT_SSL_VERIFYHOST  => false,
    );
    $curl               = curl_init();
    curl_setopt_array($curl, $defaults);
    $curl_response      = curl_exec($curl);
    $json_objekat       = json_decode($curl_response);

    // DUMP THE CURL-ERROR INFORMATION:
    var_dump(curl_error($curl));
    curl_close($curl);

##EDITS##Depending on what you are attempting to do; i think you may need an Access Code for this to work correctly and you can get it here:

And when you do; all you have to do is modify your code and add the Authorisation code...

Hello, buddy!

责编内容by:Hello, buddy! (源链)。感谢您的支持!

您可能感兴趣的

Exception Handling in Spring Boot REST Web Service... If an exception occurs when processing an HTTP request in your services, you should return a ...
Alamofire和AFNetworking中https相关知识点 首先,配置https服务器需要一个证书,这个证书可以从某些机构获得,也可以自己通过工具生成。 这样的请求不会触发Apple的相关代理方法 (URLSession:task:didReceiveC...
Working with the Azure Storage REST API in automat... Authenticom's Logo This is a guest post by Chris Kirby, Director of Technology at ...
为何你会被强插广告/盗号?谈HTTPS连接的那些事... 相信很多朋友都遇到过网页被强插广告的情况,好端端一个干净的页面,动不动就被插了个屠龙宝刀点击就送的小窗口,看着就心烦。 这种网页劫持强插广告的现象,在中国非常常见,往往是运营商进行HTTP劫持所造...
node.js Express RESTful API 认证 接上一篇文章 《node.js Express 创建RESTful API》 1.安装依赖node-token-jwt,morgan npm install jsonwebtok...