色www,五月婷婷深爱五月,午夜国产一级片,色噜噜综合,国产大胸无码视频,清纯美女被操黄网站在线观看,波多野结衣av高清一区二区三区

php獲取新浪微博數(shù)據(jù)API的實例代碼

時間:2025-07-06 18:15:38 php語言

php獲取新浪微博數(shù)據(jù)API的實例代碼

  分享下php取得新浪微博數(shù)據(jù)API的一個例子,學習下在php編程中,使用新浪微博數(shù)據(jù)API進行開發(fā)的方法,感興趣的朋友可以參考下。

  php獲取新浪微博數(shù)據(jù)API

  要取得新浪微博的數(shù)據(jù),可以通過其提供的API,地址:/pic/wiki/API文檔_V2。

  獲取數(shù)據(jù)的方法:

  復制代碼 代碼示例:

  <?php

  /**

  * 通過新浪微博數(shù)據(jù)API取得微博數(shù)據(jù)

  * edit: www.jbxue.com

  */

  function getWeiboData()

  {

  $count = 15;

  /pic/strong>

  $url = "/pic/2/statuses/home_timeline.json?source=123456789&count=".$count."&page=1";

  echo $url.'<br />';

  $curl = curl_init();

  curl_setopt($curl, CURLOPT_URL, $url);

  /pic/p>

  /pic/p>

  /pic/p>

  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

  /pic/strong>

  curl_setopt($curl, CURLOPT_USERPWD, "username:password");

  $data = curl_exec($curl);

  curl_close($curl);

  $result = json_decode($data, true);

  echo '<pre>';

  print_r($result);

  echo '</pre>';

  }

  ?>

  說明:

  json_decode($data) 會輸出一個對象,而json_decode($data, true) 則強制輸出為數(shù)組。

  獲取數(shù)組則使用了 CURL 庫。

【php獲取新浪微博數(shù)據(jù)API的實例代碼】相關文章:

PHP實用的代碼實例08-17

PHP開發(fā)微信支付實例代碼12-19

學習php分頁代碼實例12-06

PHP獲取MySQL數(shù)據(jù)庫里所有表的實現(xiàn)代碼11-04

php網(wǎng)站來路獲取代碼10-09

PHP時間戳使用實例代碼03-10

實用的PHP實例代碼20個02-03

實用的PHP語言實例代碼12-15

最實用的PHP實例代碼21個02-21