コード例 #1
0
 /**
  * @return RemoteContentRequest
  */
 private function createRemoteContentRequest($oauthParams, $method, $url, $headers, $contentType, $postBody, $options)
 {
     $paramLocation = $this->accessorInfo->getParamLocation();
     $newHeaders = array();
     // paramLocation could be overriden by a run-time parameter to fetchRequest
     switch ($paramLocation) {
         case OAuthStoreVars::$OAuthParamLocation['AUTH_HEADER']:
             if ($headers != null) {
                 $newHeaders = $headers;
             }
             $authHeader = array();
             $authHeader = $this->getAuthorizationHeader($oauthParams);
             $newHeaders["Authorization"] = $authHeader;
             break;
         case OAuthStoreVars::$OAuthParamLocation['POST_BODY']:
             if (!ShindigOAuthUtil::isFormEncoded($contentType)) {
                 throw new GadgetException("Invalid param: OAuth param location can only " . "be post_body if post body if of type x-www-form-urlencoded");
             }
             if (!isset($postBody) || count($postBody) == 0) {
                 $postBody = ShindigOAuthUtil::getPostBodyString($oauthParams);
             } else {
                 $postBody = $postBody . "&" . ShindigOAuthUtil::getPostBodyString($oauthParams);
             }
             break;
         case OAuthStoreVars::$OAuthParamLocation['URI_QUERY']:
             $url = ShindigOAuthUtil::addParameters($url, $oauthParams);
             break;
     }
     $rcr = new RemoteContentRequest($url);
     $rcr->createRemoteContentRequest($method, $url, $newHeaders, null, $options);
     $rcr->setPostBody($postBody);
     return $rcr;
 }