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


PHP HTTP_Request::getRequestCode方法代码示例

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


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

示例1: send

 /**
  * send
  * This method sends a trackback to the trackback_url saved in it. The 
  * data array of the trackback object can be completed by submitting the
  * necessary data through the $data parameter of this method.
  * The following data has to be set to call this method:
  *              'title'             Title of the weblog entry sending the trackback.
  *              'url'               URL of the weblog entry sending the trackback.
  *              'excerpt'           Excerpt of the weblog entry sending the trackback.
  *              'blog_name'         Name of the weblog sending the trackback.
  *              'trackback_url'     URL to send the trackback to.
  * Services_Trackback::send() requires PEAR::HTTP_Request. The options for the HTTP_Request
  * object are stored in the global options array using the key 'http_request'.
  *
  * @since 0.3.0
  * @access public
  * @param string $data Additional data to complete the trackback.
  * @return mixed True on success, otherwise PEAR_Error.
  */
 function send($data = null)
 {
     // Load HTTP_Request
     @(require_once 'HTTP/Request.php');
     if (!class_exists('HTTP_Request')) {
         return PEAR::raiseError('Unable to load PEAR::HTTP_Request.');
     }
     // Consistancy check
     if (!isset($data)) {
         $data = array();
     }
     $this->_data = array_merge($this->_data, $data);
     $necessaryData = array('title', 'url', 'excerpt', 'blog_name', 'trackback_url');
     $res = $this->_checkData($necessaryData);
     if (PEAR::isError($res)) {
         return $res;
     }
     // Get URL
     $url = str_replace('&', '&', $this->_data['trackback_url']);
     // Changed in 0.5.0 All HTTP_Request options are now supported.
     $options = $this->_options['httpRequest'];
     $options['timeout'] = $this->_options['timeout'];
     // Create new HTTP_Request
     $req = new HTTP_Request($url, $options);
     $req->setMethod(HTTP_REQUEST_METHOD_POST);
     // Add HTTP headers
     $req->addHeader("User-Agent", $options['useragent']);
     // Adding data to send
     $req->addPostData('url', $this->_data['url']);
     $req->addPostData('title', $this->_data['title']);
     $req->addPostData('blog_name', $this->_data['blog_name']);
     $req->addPostData('excerpt', strip_tags($this->_data['excerpt']));
     // Send POST request
     $res = $req->sendRequest();
     if (PEAR::isError($res)) {
         return $res;
     }
     // Check return code
     if ($req->getResponseCode() != 200) {
         return PEAR::raiseError('Host returned Error ' . $req->getRequestCode() . '.');
     }
     return $this->_interpretTrackbackResponse($req->getResponseBody());
 }
开发者ID:kaz6120,项目名称:BitWiki,代码行数:62,代码来源:Trackback.php


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