當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Google_Http_Request::setRequestMethod方法代碼示例

本文整理匯總了PHP中Google_Http_Request::setRequestMethod方法的典型用法代碼示例。如果您正苦於以下問題:PHP Google_Http_Request::setRequestMethod方法的具體用法?PHP Google_Http_Request::setRequestMethod怎麽用?PHP Google_Http_Request::setRequestMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Google_Http_Request的用法示例。


在下文中一共展示了Google_Http_Request::setRequestMethod方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: processEntityRequest

 public function processEntityRequest($io, $client)
 {
     $req = new Google_Http_Request("http://localhost.com");
     $req->setRequestMethod("POST");
     // Verify that the content-length is calculated.
     $req->setPostBody("{}");
     $io->processEntityRequest($req);
     $this->assertEquals(2, $req->getRequestHeader("content-length"));
     // Test an empty post body.
     $req->setPostBody("");
     $io->processEntityRequest($req);
     $this->assertEquals(0, $req->getRequestHeader("content-length"));
     // Test a null post body.
     $req->setPostBody(null);
     $io->processEntityRequest($req);
     $this->assertEquals(0, $req->getRequestHeader("content-length"));
     // Set an array in the postbody, and verify that it is url-encoded.
     $req->setPostBody(array("a" => "1", "b" => 2));
     $io->processEntityRequest($req);
     $this->assertEquals(7, $req->getRequestHeader("content-length"));
     $this->assertEquals(Google_IO_Abstract::FORM_URLENCODED, $req->getRequestHeader("content-type"));
     $this->assertEquals("a=1&b=2", $req->getPostBody());
     // Verify that the content-type isn't reset.
     $payload = array("a" => "1", "b" => 2);
     $req->setPostBody($payload);
     $req->setRequestHeaders(array("content-type" => "multipart/form-data"));
     $io->processEntityRequest($req);
     $this->assertEquals("multipart/form-data", $req->getRequestHeader("content-type"));
     $this->assertEquals($payload, $req->getPostBody());
 }
開發者ID:sacredwebsite,項目名稱:scalr,代碼行數:30,代碼來源:IoTest.php

示例2: delete

 public static function delete(Contact $toDelete)
 {
     $client = GoogleHelper::getClient();
     $req = new \Google_Http_Request($toDelete->editURL);
     $req->setRequestHeaders(array('content-type' => 'application/atom+xml; charset=UTF-8; type=feed'));
     $req->setRequestMethod('DELETE');
     $client->getAuth()->authenticatedRequest($req);
 }
開發者ID:rapidwebltd,項目名稱:php-google-contacts-v3-api,代碼行數:8,代碼來源:ContactFactory.php

示例3: create

 public static function create($name, $phoneNumber, $emailAddress)
 {
     $doc = new \DOMDocument();
     $doc->formatOutput = true;
     $entry = $doc->createElement('atom:entry');
     $entry->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:atom', 'http://www.w3.org/2005/Atom');
     $entry->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:gd', 'http://schemas.google.com/g/2005');
     $entry->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:gd', 'http://schemas.google.com/g/2005');
     $doc->appendChild($entry);
     $title = $doc->createElement('title', $name);
     $entry->appendChild($title);
     $email = $doc->createElement('gd:email');
     $email->setAttribute('rel', 'http://schemas.google.com/g/2005#work');
     $email->setAttribute('address', $emailAddress);
     $entry->appendChild($email);
     $contact = $doc->createElement('gd:phoneNumber', $phoneNumber);
     $contact->setAttribute('rel', 'http://schemas.google.com/g/2005#work');
     $entry->appendChild($contact);
     $xmlToSend = $doc->saveXML();
     $client = GoogleHelper::getClient();
     $req = new \Google_Http_Request('https://www.google.com/m8/feeds/contacts/default/full');
     $req->setRequestHeaders(array('content-type' => 'application/atom+xml; charset=UTF-8; type=feed'));
     $req->setRequestMethod('POST');
     $req->setPostBody($xmlToSend);
     $val = $client->getAuth()->authenticatedRequest($req);
     $response = $val->getResponseBody();
     $xmlContact = simplexml_load_string($response);
     $xmlContact->registerXPathNamespace('gd', 'http://schemas.google.com/g/2005');
     $xmlContactsEntry = $xmlContact;
     $contactDetails = array();
     $contactDetails['id'] = (string) $xmlContactsEntry->id;
     $contactDetails['name'] = (string) $xmlContactsEntry->title;
     foreach ($xmlContactsEntry->children() as $key => $value) {
         $attributes = $value->attributes();
         if ($key == 'link') {
             if ($attributes['rel'] == 'edit') {
                 $contactDetails['editURL'] = (string) $attributes['href'];
             } elseif ($attributes['rel'] == 'self') {
                 $contactDetails['selfURL'] = (string) $attributes['href'];
             }
         }
     }
     $contactGDNodes = $xmlContactsEntry->children('http://schemas.google.com/g/2005');
     foreach ($contactGDNodes as $key => $value) {
         $attributes = $value->attributes();
         if ($key == 'email') {
             $contactDetails[$key] = (string) $attributes['address'];
         } elseif ($key == 'organization') {
             $contactDetails[$key] = 'hello';
             //$contactDetails[$key] = (string) $value->children()->current() ?: 'hello';
         } else {
             $contactDetails[$key] = (string) $value;
         }
     }
     return new Contact($contactDetails);
 }
開發者ID:stewhouston,項目名稱:tcg-yasuo,代碼行數:56,代碼來源:ContactFactory.php

示例4: _create_contact


//.........這裏部分代碼省略.........
     $emailDom->setAttribute('rel', 'http://schemas.google.com/g/2005#work');
     $emailDom->setAttribute('address', $emailAddress);
     $entry->appendChild($emailDom);
     if (!empty($phoneNumber)) {
         $phoneNumberDom = $doc->createElement('gd:phoneNumber', $phoneNumber);
         $phoneNumberDom->setAttribute('rel', 'http://schemas.google.com/g/2005#main');
         $phoneNumberDom->setAttribute('primary', 'true');
         $entry->appendChild($phoneNumberDom);
     }
     if (!empty($workPhone)) {
         $phoneNumberDom = $doc->createElement('gd:phoneNumber', $workPhone);
         $phoneNumberDom->setAttribute('rel', 'http://schemas.google.com/g/2005#work');
         $entry->appendChild($phoneNumberDom);
     }
     if (!empty($cellPhone)) {
         $phoneNumberDom = $doc->createElement('gd:phoneNumber', $cellPhone);
         $phoneNumberDom->setAttribute('rel', 'http://schemas.google.com/g/2005#mobile');
         $entry->appendChild($phoneNumberDom);
     }
     if (!empty($faxPhone)) {
         $phoneNumberDom = $doc->createElement('gd:phoneNumber', $faxPhone);
         $phoneNumberDom->setAttribute('rel', 'http://schemas.google.com/g/2005#fax');
         $entry->appendChild($phoneNumberDom);
     }
     if (!empty($address)) {
         $postalAddressDom = $doc->createElement('gd:postalAddress', $address);
         $postalAddressDom->setAttribute('rel', 'http://schemas.google.com/g/2005#work');
         $postalAddressDom->setAttribute('primary', 'true');
         $entry->appendChild($postalAddressDom);
     }
     if (!empty($company) || !empty($title)) {
         $orgDom = $doc->createElement('gd:organization');
         $orgDom->setAttribute('rel', 'http://schemas.google.com/g/2005#work');
         $orgDom->setAttribute('primary', 'true');
         if (isset($company) && !empty($company)) {
             file_put_contents(dirname(__FILE__) . '/update.txt', PHP_EOL . 'Company: ' . PHP_EOL . var_export($company, true) . PHP_EOL, FILE_APPEND);
             $orgNameDom = $doc->createElement('gd:orgName', $company);
             $orgDom->appendChild($orgNameDom);
         }
         if (isset($title) && !empty($title)) {
             file_put_contents(dirname(__FILE__) . '/update.txt', PHP_EOL . 'Title: ' . PHP_EOL . var_export($title, true) . PHP_EOL, FILE_APPEND);
             $orgTitleDom = $doc->createElement('gd:orgTitle', $title);
             $orgDom->appendChild($orgTitleDom);
         }
         $entry->appendChild($orgDom);
     }
     if (!empty($referral)) {
         $referralDom = $doc->createElement('gd:extendedProperty');
         $referralDom->setAttribute('name', 'referral');
         $referralDom->setAttribute('value', $referral);
         $entry->appendChild($referralDom);
     }
     if (!empty($manager)) {
         $managerDom = $doc->createElement('gd:extendedProperty');
         $managerDom->setAttribute('name', 'manager');
         $managerDom->setAttribute('value', $manager);
         $entry->appendChild($managerDom);
     }
     if (!empty($birthday)) {
         $birthdayDom = $doc->createElement('gContact:birthday');
         $birthdayDom->setAttribute('when', $birthday);
         $entry->appendChild($birthdayDom);
     }
     $birthdayDom = $doc->createElement('gContact:relation');
     $birthdayDom->setAttribute('label', 'Ontraport Contact');
     $entry->appendChild($birthdayDom);
     if (!empty($url)) {
         $websiteDom = $doc->createElement('gContact:website');
         $websiteDom->setAttribute('href', $url);
         $websiteDom->setAttribute('rel', 'http://schemas.google.com/g/2005#profile');
         $websiteDom->setAttribute('primary', 'true');
         $entry->appendChild($websiteDom);
     }
     $groupMemDom = $doc->createElement('gContact:groupMembershipInfo');
     $groupMemDom->setAttribute('href', $industryGroup['id']);
     $groupMemDom->setAttribute('deleted', 'false');
     $entry->appendChild($groupMemDom);
     $xmlToSend = $doc->saveXML();
     file_put_contents(dirname(__FILE__) . '/update.txt', PHP_EOL . 'Request XML' . PHP_EOL . $xmlToSend . PHP_EOL, FILE_APPEND);
     if ($cid !== false) {
         file_put_contents(dirname(__FILE__) . '/update.txt', PHP_EOL . '%%%% Priming UPDATE request header with CID: ' . $cid, FILE_APPEND);
         $req = new Google_Http_Request('https://www.google.com/m8/feeds/contacts/default/full/' . $cid);
         $req->setRequestHeaders(array('content-type' => 'application/atom+xml; charset=UTF-8; type=feed'));
         $req->setRequestMethod('PUT');
         $req->setPostBody($xmlToSend);
     } else {
         file_put_contents(dirname(__FILE__) . '/update.txt', PHP_EOL . '++++ Priming CREATE request header', FILE_APPEND);
         $req = new Google_Http_Request('https://www.google.com/m8/feeds/contacts/default/full');
         $req->setRequestHeaders(array('content-type' => 'application/atom+xml; charset=UTF-8; type=feed'));
         $req->setRequestMethod('POST');
         $req->setPostBody($xmlToSend);
     }
     file_put_contents(dirname(__FILE__) . '/update.txt', PHP_EOL . 'Making request', FILE_APPEND);
     $val = $client->getAuth()->authenticatedRequest($req);
     $response = $val->getResponseBody();
     file_put_contents(dirname(__FILE__) . '/update.txt', PHP_EOL . PHP_EOL . '===RESPONSE===' . PHP_EOL . $response . PHP_EOL . PHP_EOL, FILE_APPEND);
     $xmlContact = simplexml_load_string($response);
     $xmlContact->registerXPathNamespace('gd', 'http://schemas.google.com/g/2005');
     return OPContactProxy::xml2array($xmlContact);
 }
開發者ID:tronnetdevops,項目名稱:op-contacts-proxy,代碼行數:101,代碼來源:index.php


注:本文中的Google_Http_Request::setRequestMethod方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。