Using php curl to retrieve Sina's API data solution

Source: Internet
Author: User
Using php's curl to retrieve Sina's API data, I spliced Sina's API to retrieve some Weibo data. This is the link I spliced: api. weibo. com2statusesrepost_timeline.json? Id1_1834027857481 & amp; page1 & amp; count100 & amp; access_token2.00Oa6 unable to obtain Sina API data using php curl
I spliced Sina's API to get some Weibo data. Here is the link I spliced:
Https://api.weibo.com/2/statuses/repost_timeline.json? Id = 3681834027857481 & page = 1 & count = 100 & access_token = 2.00Oa6w2CHIARMB96820f87ebEnJkeE
If you enter this link directly in the browser, roommate data, but I cannot get it if I use the crul function.
The following is my function: (Note: The $ url is the link above)
$ Ch = curl_init ();
// 2. set Request options, including specific URLs
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
// 3. execute a cURL session and obtain related Replies
$ Response = curl_exec ($ ch );
// 4. release the cURL handle and close a cURL session
Curl_close ($ ch );
The value of $ response I printed is false.
------ Solution --------------------
Add
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, 0 );

Protocol header https
Curl enables certificate verification by default
So close it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.