Exemple #1
0
 public function testRestFixesPathWithMissingSlashes()
 {
     $expXml = file_get_contents($this->path . 'returnString.xml');
     $response = "HTTP/1.0 200 OK\r\n" . "X-powered-by: PHP/5.2.0\r\n" . "Content-type: text/xml\r\n" . "Content-length: " . strlen($expXml) . "\r\n" . "Server: Apache/1.3.34 (Unix) PHP/5.2.0)\r\n" . "Date: Tue, 06 Feb 2007 15:01:47 GMT\r\n" . "Connection: close\r\n" . "\r\n" . $expXml;
     $this->adapter->setResponse($response);
     $rest = new Client\RestClient('http://framework.zend.com');
     $response = $rest->restGet('rest');
     $this->assertTrue($response instanceof Response);
     $this->assertContains($expXml, $response->getBody());
 }
Exemple #2
0
 public function findLocationByLocationName($locationName)
 {
     //http://maps.google.com/maps/geo?q=Kiev%20/%20Kyiv,%20Ukraine&output=json&oe=utf8
     $client = new Rest\Client\RestClient();
     $client->setUri("http://maps.google.com");
     $client->setHeaders('Accept-Charset', 'ISO-8859-1,utf-8');
     $_query = array('q' => $locationName, 'output'=>'json', 'oe'=>'utf8');
     $response = $client->restGet('/maps/geo', $_query);
     $location = Json\Json::decode($response->getBody());
     if (empty($location->Placemark)) return null;
     $placemark = $location->Placemark;
     if (!count($placemark)) return null;
     $place = current($placemark);
     list($long, $lat) = $place->Point->coordinates;
     return new Location($lat, $long);
 }