当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Rest_Client::continue方法代码示例

本文整理汇总了PHP中Zend_Rest_Client::continue方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Rest_Client::continue方法的具体用法?PHP Zend_Rest_Client::continue怎么用?PHP Zend_Rest_Client::continue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Rest_Client的用法示例。


在下文中一共展示了Zend_Rest_Client::continue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wiki

 /**
  *  rest-client.docx
  * Gets the first wiki-text before the Table of Content
  * @author TSCM
  * @since 20150102
  * @param string - a Name or Booktitle , exp: "Lord of the Rings"
  * @return string - html code line
  * Explanation
  * //Base Url:
  * http://en.wikipedia.org/w/api.php?action=query
  *
  * //tell it to get revisions:
  * &prop=revisions
  *
  * //define page titles separated by pipes. In the example i used t-shirt company threadless
  * &titles=whatever|the|title|is
  *
  * //specify that we want the page content
  * &rvprop=content
  *
  * //I want my data in JSON, default is XML
  * &format=json
  *
  * //lets you choose which section you want. 0 is the first one.
  * &rvsection=0
  *
  * //tell wikipedia to parse it into html for you
  * &rvparse=1
  *
  * //only geht the "first"-Description of the wikipage, the one before the Table of Contents
  * &exintro=1
  *
  * //if I want to select something, I use action query, update / delete would be different
  * &action=query
  */
 public static function wiki($query)
 {
     // load Zend classes
     require_once 'Zend/Loader.php';
     Zend_Loader::loadClass('Zend_Rest_Client');
     $decodeUtf8 = 0;
     //is decoding needed? Default not
     // define search query
     $wikiQuery = str_replace(" ", "_", $query);
     try {
         //initialize REST client
         $lang = I18n::lang();
         $wikiLang = strtolower($lang);
         $webPagePrefix = "http://";
         $webPageUrl = ".wikipedia.org/w/api.php";
         //build the wiki api. be sure, that $wikiLang exists, exp: de or en
         $wikipedia = new Zend_Rest_Client($webPagePrefix . $wikiLang . $webPageUrl);
         $wikipedia->action('query');
         //standard action, i want to GET...
         $wikipedia->prop('extracts');
         //what do i want to extract? page info
         $wikipedia->exintro('1');
         // only extract the intro? (pre-Table of content) 1= yes, 0=now
         $wikipedia->titles($wikiQuery);
         //title is the wiki title to be found
         $wikipedia->format('xml');
         //what format should be returned? exp: json, txt, php,
         $wikipedia->continue('');
         //has to be set, otherwise wikimedia sends a warning
         // perform request
         // iterate over XML result set
         $result = $wikipedia->get();
         //print_r($result);
         $rs = $result->query->pages->page->extract;
         if ($decodeUtf8) {
             $rs = utf8_decode($rs);
         }
         //strip html Tags to get a clean string
         $rsFinal = strip_tags($rs);
         return $rsFinal;
     } catch (Exception $e) {
         die('ERROR: ' . $e->getMessage());
     }
 }
开发者ID:Makae,项目名称:ch.bfh.bti7054.w2014.q.groot,代码行数:79,代码来源:class.utilities.php


注:本文中的Zend_Rest_Client::continue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。