當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。