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.