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


PHP HTTPRequest::addPostData方法代码示例

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


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

示例1: replace

 function replace($photo, $photo_id, $async = null)
 {
     $upload_req = new HTTPRequest();
     $upload_req->setMethod("POST");
     $upload_req->setURL($this->Replace);
     //$upload_req->clearPostData();
     //Process arguments, including method and login data.
     $args = array("api_key" => $this->api_key, "photo_id" => $photo_id, "async" => $async);
     if (!empty($this->email)) {
         $args = array_merge($args, array("email" => $this->email));
     }
     if (!empty($this->password)) {
         $args = array_merge($args, array("password" => $this->password));
     }
     if (!empty($this->token)) {
         $args = array_merge($args, array("auth_token" => $this->token));
     } elseif (!empty($_SESSION['phpFlickr_auth_token'])) {
         $args = array_merge($args, array("auth_token" => $_SESSION['phpFlickr_auth_token']));
     }
     ksort($args);
     $auth_sig = "";
     foreach ($args as $key => $data) {
         if ($data !== null) {
             $auth_sig .= $key . $data;
             $upload_req->addPostData($key, $data);
         }
     }
     if (!empty($this->secret)) {
         $api_sig = md5($this->secret . $auth_sig);
         $upload_req->addPostData("api_sig", $api_sig);
     }
     $photo = realpath($photo);
     $result = $upload_req->addFile("photo", $photo);
     //Send Requests
     if ($upload_req->sendRequest()) {
         $this->response = $upload_req->getResponseBody();
     } else {
         die("There has been a problem sending your command to the server.");
     }
     if ($async == 1) {
         $find = 'ticketid';
     } else {
         $find = 'photoid';
     }
     $rsp = explode("\n", $this->response);
     foreach ($rsp as $line) {
         if (ereg('<err code="([0-9]+)" msg="(.*)"', $line, $match)) {
             if ($this->die_on_error) {
                 die("The Flickr API returned the following error: #{$match[1]} - {$match[2]}");
             } else {
                 $this->error_code = $match[1];
                 $this->error_msg = $match[2];
                 $this->parsed_response = false;
                 return false;
             }
         } elseif (ereg("<" . $find . ">(.*)</", $line, $match)) {
             $this->error_code = false;
             $this->error_msg = false;
             return $match[1];
         }
     }
 }
开发者ID:cllu,项目名称:Drupal-Markdown,代码行数:62,代码来源:Flickr.php


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