本文整理汇总了PHP中Zend_Rest_Client类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Rest_Client类的具体用法?PHP Zend_Rest_Client怎么用?PHP Zend_Rest_Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Rest_Client类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction()
{
$this->_helper->viewRenderer->setNoRender(false);
$this->_helper->layout()->enableLayout();
if ($this->getRequest()->isPost()) {
if ($this->_getParam('num_cnpj') == '') {
Zend_Layout::getMvcInstance()->assign('msg_error', 'Campo CNPJ é obrigatório !');
} else {
if (strlen($this->_getParam('num_cnpj')) < 18) {
Zend_Layout::getMvcInstance()->assign('msg_error', 'CNPJ está incorreto !');
} else {
$num_cnpj = $this->_getParam('num_cnpj', '');
$this->view->assign('num_cnpj', $num_cnpj);
// Incluir arquivo de cliente web service
require_once 'Zend/Rest/Client.php';
// Criar classe da conexão com o web-service
$clientRest = new Zend_Rest_Client('http://' . $_SERVER['HTTP_HOST'] . '/Consulta/sintegra');
// Fazer requisição do registro
$result = $clientRest->ConsultarRegistro($num_cnpj, $this->generateAuthKey())->get();
$result = json_decode($result);
if (count($result) <= 0) {
Zend_Layout::getMvcInstance()->assign('msg_error', 'Não foi encontrado nenhum registro para o CNPJ ' . $num_cnpj);
} else {
$result = get_object_vars($result[0]);
Zend_Layout::getMvcInstance()->assign('msg_success', 'Exibindo dados do CNPJ ' . $num_cnpj);
$this->view->assign('result', $result);
}
}
}
}
}
开发者ID:DaviSouto,项目名称:UpLexis_Sintegra-Teste-PHP,代码行数:31,代码来源:ConsultaController.php
示例2: execute
public function execute()
{
$action = SJB_Request::getVar('action');
$sessionUpdateData = SJB_Session::getValue(self::SESSION_UPDATE_TAG);
if ($action == 'mark_as_closed') {
if (is_array($sessionUpdateData)) {
$sessionUpdateData['closed_by_user'] = true;
SJB_Session::setValue(self::SESSION_UPDATE_TAG, $sessionUpdateData);
}
exit;
}
// check updates
$serverUrl = SJB_System::getSystemSettings('SJB_UPDATE_SERVER_URL');
$version = SJB_System::getSystemSettings('version');
// CHECK FOR UPDATES
$updateInfo = SJB_Session::getValue(self::SESSION_UPDATE_TAG);
if (empty($updateInfo)) {
// check URL for accessibility
$ch = curl_init($serverUrl);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
$urlInfo = curl_getinfo($ch);
$availableVersion = array();
$updateStatus = '';
if ($urlInfo['http_code'] > 0) {
// OK. Url is accessible - lets get update info
try {
$client = new Zend_Rest_Client($serverUrl);
$result = $client->isUpdateAvailable($version['major'], $version['minor'], $version['build'], SJB_System::getSystemSettings('USER_SITE_URL'))->get();
if ($result->isSuccess()) {
$updateStatus = (string) $result->updateStatus;
switch ($updateStatus) {
case 'available':
$availableVersion = array('major' => (string) $result->version->major, 'minor' => (string) $result->version->minor, 'build' => (string) $result->version->build);
break;
}
}
} catch (Exception $e) {
SJB_Error::writeToLog('Update Check: ' . $e->getMessage());
}
}
$updateInfo = array('availableVersion' => $availableVersion, 'updateStatus' => $updateStatus);
SJB_Session::setValue(self::SESSION_UPDATE_TAG, $updateInfo);
} else {
if (isset($updateInfo['availableVersion']) && !empty($updateInfo['availableVersion'])) {
if ($updateInfo['availableVersion']['build'] <= $version['build']) {
$updateInfo = array('availableVersion' => $updateInfo['availableVersion'], 'updateStatus' => 'none');
}
}
}
echo json_encode($updateInfo);
exit;
}
开发者ID:Maxlander,项目名称:shixi,代码行数:54,代码来源:update_check.php
示例3: setUp
/**
* @return void
*/
public function setUp()
{
$httpClient = new Zend_Http_Client();
$httpClient->setConfig(array('useragent' => 'Zend_Service_Delicious - Unit tests/0.1', 'keepalive' => true));
Zend_Rest_Client::setHttpClient($httpClient);
$this->_delicious = new Zend_Service_Delicious();
}
开发者ID:travisj,项目名称:zf,代码行数:10,代码来源:PublicDataTest.php
示例4: setUp
public function setUp()
{
$this->adapter = new Zend_Http_Client_Adapter_Test();
$client = new Zend_Http_Client(null, array('adapter' => $this->adapter));
Zend_Rest_Client::setHttpClient($client);
$this->shipapi = new ShipApi('user', 'pass', 'http://www.test.com');
}
开发者ID:bkaney,项目名称:shipapi-client-php,代码行数:7,代码来源:Request_test.php
示例5: authenticate
/**
* Connects to the AUTH API in Teleserv to authenticate an agent against his HOME credentials.
*
* @return Zend_Auth_Result
* @author Bryan Zarzuela
* @throws Zend_Auth_Adapter_Exception
*/
public function authenticate()
{
// This is not a real salt. I have to fix this one of these days.
// Encrypt the password before sending over the wire.
$password = sha1($this->_password . 'andpepper');
$client = new Zend_Rest_Client($this->_url);
$response = $client->authenticate($this->_username, $password)->post();
if (!$response->isSuccess()) {
throw new Zend_Auth_Adapter_Exception("Cannot authenticate");
}
if (!$response->success()) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE, null);
}
$data = unserialize($response->data());
// var_dump($data);
$identity = new Teleserv_Auth_Identity($data);
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
}
开发者ID:kenncapara,项目名称:emaxx,代码行数:25,代码来源:Adapter.php
示例6: setUp
/**
*
* @return void
*/
public function setUp()
{
if (!constant('TESTS_ZEND_SERVICE_DELICIOUS_ENABLED')) {
$this->markTestSkipped('Zend_Service_Delicious online tests are not enabled');
}
$httpClient = new Zend_Http_Client();
$httpClient->setConfig(array('useragent' => 'Zend_Service_Delicious - Unit tests/0.1', 'keepalive' => true));
Zend_Rest_Client::setDefaultHTTPClient($httpClient);
$this->_delicious = new Zend_Service_Delicious(self::TEST_UNAME, self::TEST_PASS);
}
开发者ID:bradley-holt,项目名称:zf2,代码行数:14,代码来源:PrivateDataTest.php
示例7: findPackstations
/**
* Call corresponding web service method and return the results.
*
* @deprecated Zend_Rest_Client does not format URI accordingly
* @param array $params
* @return array The parsed packstation data
* @throws Dhl_Account_Exception
*/
public function findPackstations(array $params)
{
/* @var $helper Dhl_Account_Helper_Data */
$helper = Mage::helper('dhlaccount/data');
$params = $this->getDefaultParams() + $params;
try {
$result = $this->getClient()->postfinder($params)->get();
} catch (Zend_Rest_Client_Result_Exception $e) {
$response = $this->client->getHttpClient()->getLastResponse();
$helper->log($this->client->getHttpClient()->getLastRequest());
$helper->log(sprintf("%s\nHTTP/%s %s %s", $e->getMessage(), $response->getVersion(), $response->getStatus(), $response->getMessage()));
throw new Dhl_Account_Exception($helper->__('An error occured while retrieving the packstation data.'));
}
// TODO(nr): transform web service response to usable output.
return $result;
}
开发者ID:igorvasiliev4,项目名称:magento_code,代码行数:24,代码来源:Adapter.php
示例8: __construct
public function __construct($type)
{
$this->_type = $type;
$app = $GLOBALS['application']->getOption('app');
$message_config = $app['messages'][$type];
$server = $message_config['server'];
$context = $message_config['context'];
unset($message_config['server']);
unset($message_config['context']);
$this->_messages = new StdClass();
foreach ($message_config as $key => $method) {
$key = str_replace(' ', '', ucwords(str_replace('_', ' ', $key)));
$this->_messages->{$key} = $context . $method;
}
Zend_Rest_Client::__construct($server);
$this->getHttpClient()->setHeaders('Accept-Encoding', 'plain');
}
开发者ID:ramcoelho,项目名称:miidle.github.com,代码行数:17,代码来源:Consumer.php
示例9: search
function search()
{
// load Zend classes
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Rest_Client');
// define category prefix
$prefix = 'hollywood';
// initialize REST client
$wikipedia = new Zend_Rest_Client('http://en.wikipedia.org/w/api.php');
// set query parameters
$wikipedia->action('query');
$wikipedia->list('allcategories');
//All list queries return a limited number of results.
$wikipedia->acprefix($prefix);
$wikipedia->format('xml');
// perform request and iterate over XML result set
$result = $wikipedia->get();
//echo "<ol>";
foreach ($result->query->allcategories->c as $c) {
//<a href="http://www.wikipedia.org/wiki/Category:
echo $c . "<br>";
}
}
开发者ID:Makae,项目名称:ch.bfh.bti7054.w2014.q.groot,代码行数:23,代码来源:utility.php
示例10: Zend_Rest_Client
- http://framework.zend.com/manual/en/zend.rest.client.html
- http://www.pixelated-dreams.com/archives/243-Next-Generation-REST-Web-Services-Client.html
**/
require 'Zend/Rest/Client.php';
$taskr_site_url = "http://localhost:7007";
/**
If your Taskr server is configured to require authentication, uncomment the next block
and change the username and password to whatever you have in your server's config.yml.
**/
//$username = 'taskr';
//$password = 'task!';
//Zend_Rest_Client::getHttpClient()->setAuth($username, $password);
/**
Initialize the REST client.
**/
$rest = new Zend_Rest_Client($taskr_site_url);
/**
Retreiving the list of all scheduled Tasks
**/
$tasks = $rest->get("/tasks.xml");
// $tasks is a SimpleXml object, so calling print_r($result) will let
// you see all of its data.
//
// Here's an example of how to print out all of the tasks as an HTML list:
if ($tasks->task) {
echo "<ul>\n";
foreach ($tasks->task as $task) {
echo "\t<li>" . $task->name . "</li>\n";
echo "\t<ul>\n";
echo "\t\t<li>execute " . $task->{'schedule-method'} . " " . $task->{'schedule-when'} . "</li>\n";
echo "\t\t<li>created by " . $task->{'created-by'} . " on " . $task->{'created-on'} . "</li>\n";
开发者ID:jumping,项目名称:taskr,代码行数:31,代码来源:php_client_example.php
示例11: Zend_Rest_Client
<?php
/**
* @file
* @ingroup DAPCPTest
*
* @author Dian
*/
require_once 'Zend/Rest/Client.php';
$client = new Zend_Rest_Client('http://localhost/mw/api.php?action=wspcp&format=xml');
#$client->readPage("WikiSysop", NULL, NULL, NULL, NULL, "Main Page")->get();
$client->method("readPage");
$client->title("Main Page");
$result = $client->get();
var_dump($result->wspcp()->text);
//echo $client->createPage("WikiSysop", NULL, NULL, NULL, NULL, "REST Test", "Adding some content")->get()->getIterator()->asXML();
//$__obj = $client->readPage("WikiSysop", NULL, NULL, NULL, NULL, "Main Page")->get();
//$__res = $__obj->__toString();
//var_dump($client->readPage("WikiSysop", NULL, NULL, NULL, NULL, "Main Page")->get());
//echo $client->login("WikiSysop", "!>ontoprise?")->get();
//var_dump($client->sayHello("Tester", "now")->get());
开发者ID:seedbank,项目名称:old-repo,代码行数:21,代码来源:TestZendRESTClient.php
示例12: testRestPut
public function testRestPut()
{
$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);
$reqXml = file_get_contents($this->path . 'returnInt.xml');
$response = $this->rest->restPut('/rest/', $reqXml);
$this->assertTrue($response instanceof Zend_Http_Response);
$body = $response->getBody();
$this->assertContains($expXml, $response->getBody());
$request = Zend_Rest_Client::getHttpClient()->getLastRequest();
$this->assertContains($reqXml, $request, $request);
}
开发者ID:nbcutech,项目名称:o3drupal,代码行数:23,代码来源:ClientTest.php
示例13: _restFileUpload
/**
* Perform a rest post throwing an exception if result failed
*
* @param string $method
* @param array $options
* @param array $defaultOptions
* @return Zend_Rest_Client_Result
*/
protected function _restFileUpload($method, $file, $param, array $options, array $defaultOptions = array())
{
$options = $this->_prepareOptions($method, $options, $defaultOptions);
$client = Zend_Rest_Client::getHttpClient();
$client->setUri($this->getScribdClient()->getRestClient()->getUri());
$client->setParameterGet($options);
$client->setFileUpload($file, $param);
$response = $client->request('POST');
if ($response->isError()) {
$code = $response->extractCode($response->asString());
/**
* @see Zym_Service_Scribd_Exception
*/
require_once 'Zym/Service/Scribd/Exception.php';
throw new Zym_Service_Scribd_Exception($response->getMessage(), $code);
}
return $this->_handleResponse($response);
}
开发者ID:BGCX262,项目名称:zym-svn-to-git,代码行数:31,代码来源:Abstract.php
示例14: testFindAllByMasterFilterAlias
/**
* @group EricssonListPagingInt
*/
public function testFindAllByMasterFilterAlias()
{
Zend_Rest_Client::getHttpClient()->setConfig(array('timeout' => 60));
$rawFilters = array('alias' => 'alias');
$filterList = SimService::getInstance()->buildFilterList($rawFilters);
$filters = array('organizationId' => Application\Model\Organization\OrgMasterModel::ORG_TYPE . '-' . 'master11111111111111111111111111', 'filterList' => $filterList);
$sims = $this->simMapper->findAll($filters, array('count' => 100));
$this->assertNotNull($sims);
$this->assertGreaterThanOrEqual('1', $sims->getCount());
}
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:13,代码来源:SimMapperEricssonIntListTest.php
示例15: tearDown
public function tearDown()
{
Zend_Rest_Client::setHttpClient($this->_httpClientOriginal);
}
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:4,代码来源:OnlineTest.php
示例16: wiki
/**
* rest-client.docx
* Gets the first wiki-text before the Table of Content
* @author TSCM
* @since 20150102
* @param string - a Name or Booktitle , exp: "Lord of the Rings"
* @return string - html code line
* Explanation
* //Base Url:
* http://en.wikipedia.org/w/api.php?action=query
*
* //tell it to get revisions:
* &prop=revisions
*
* //define page titles separated by pipes. In the example i used t-shirt company threadless
* &titles=whatever|the|title|is
*
* //specify that we want the page content
* &rvprop=content
*
* //I want my data in JSON, default is XML
* &format=json
*
* //lets you choose which section you want. 0 is the first one.
* &rvsection=0
*
* //tell wikipedia to parse it into html for you
* &rvparse=1
*
* //only geht the "first"-Description of the wikipage, the one before the Table of Contents
* &exintro=1
*
* //if I want to select something, I use action query, update / delete would be different
* &action=query
*/
public static function wiki($query)
{
// load Zend classes
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Rest_Client');
$decodeUtf8 = 0;
//is decoding needed? Default not
// define search query
$wikiQuery = str_replace(" ", "_", $query);
try {
//initialize REST client
$lang = I18n::lang();
$wikiLang = strtolower($lang);
$webPagePrefix = "http://";
$webPageUrl = ".wikipedia.org/w/api.php";
//build the wiki api. be sure, that $wikiLang exists, exp: de or en
$wikipedia = new Zend_Rest_Client($webPagePrefix . $wikiLang . $webPageUrl);
$wikipedia->action('query');
//standard action, i want to GET...
$wikipedia->prop('extracts');
//what do i want to extract? page info
$wikipedia->exintro('1');
// only extract the intro? (pre-Table of content) 1= yes, 0=now
$wikipedia->titles($wikiQuery);
//title is the wiki title to be found
$wikipedia->format('xml');
//what format should be returned? exp: json, txt, php,
$wikipedia->continue('');
//has to be set, otherwise wikimedia sends a warning
// perform request
// iterate over XML result set
$result = $wikipedia->get();
//print_r($result);
$rs = $result->query->pages->page->extract;
if ($decodeUtf8) {
$rs = utf8_decode($rs);
}
//strip html Tags to get a clean string
$rsFinal = strip_tags($rs);
return $rsFinal;
} catch (Exception $e) {
die('ERROR: ' . $e->getMessage());
}
}
开发者ID:Makae,项目名称:ch.bfh.bti7054.w2014.q.groot,代码行数:79,代码来源:class.utilities.php
示例17: find_artist
/**
*
* @param <type> $pString
* @return <type>
*/
public static function find_artist($pString)
{
$client = new Zend_Rest_Client("http://musicbrainz.org/ws/1/artist/");
$client->type('xml');
$client->name(str_replace(' ', '+', $pString));
return $client->get();
}
开发者ID:BGCX262,项目名称:zupal-svn-to-git,代码行数:12,代码来源:MusicBrains.php
示例18: _doRequest
/**
* @param Zend_Rest_Client $request
* @param string $path
* @param array $params
* @param string $method
* @return Zend_Http_Response
*/
protected function _doRequest($request, $path, $params, $method = 'POST')
{
if ($this->_isDebugMode()) {
$message = "{$method} {$request->getUri()}{$path} with params:\n" . print_r($params, true);
Mage::helper('codekunst_payglobe')->log($message);
}
switch ($method) {
case 'POST':
default:
$response = $request->restPost($path, $params);
break;
}
if ($this->_isDebugMode()) {
$message = "Response: {$response->getStatus()} with body:\n{$response->getBody()}";
Mage::helper('codekunst_payglobe')->log($message);
}
return $response;
}
开发者ID:jronatay,项目名称:ultimo-magento-jron,代码行数:25,代码来源:Authorization.php
示例19: itemLookup
/**
* Look up item(s) by ASIN
*
* @param string $asin Amazon ASIN ID
* @param array $options Query Options
* @see http://www.amazon.com/gp/aws/sdk/main.html/102-9041115-9057709?s=AWSEcommerceService&v=2005-10-05&p=ApiReference/ItemLookupOperation
* @throws Zend_Service_Exception
* @return Zend_Service_Amazon_Item|Zend_Service_Amazon_ResultSet
*/
public function itemLookup($asin, array $options = array())
{
$defaultOptions = array('IdType' => 'ASIN', 'ResponseGroup' => 'Small');
$options['ItemId'] = (string) $asin;
$options = $this->_prepareOptions('ItemLookup', $options, $defaultOptions);
$this->_rest->getHttpClient()->resetParameters();
$response = $this->_rest->restGet('/onca/xml', $options);
if ($response->isError()) {
/**
* @see Zend_Service_Exception
*/
require_once 'Zend/Service/Exception.php';
throw new Zend_Service_Exception('An error occurred sending request. Status code: ' . $response->getStatus());
}
$dom = new DOMDocument();
$dom->loadXML($response->getBody());
self::_checkErrors($dom);
$xpath = new DOMXPath($dom);
$xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
$items = $xpath->query('//az:Items/az:Item');
if ($items->length == 1) {
/**
* @see Zend_Service_Amazon_Item
*/
require_once 'Zend/Service/Amazon/Item.php';
return new Zend_Service_Amazon_Item($items->item(0));
}
/**
* @see Zend_Service_Amazon_ResultSet
*/
require_once 'Zend/Service/Amazon/ResultSet.php';
return new Zend_Service_Amazon_ResultSet($dom);
}
开发者ID:Mendim,项目名称:gtv-resources,代码行数:42,代码来源:Amazon.php
示例20: webSearch
/**
* Perform a web content search on search.yahoo.com. A basic query
* consists simply of a text query. Additional options that can be
* specified consist of:
* 'results' => int How many results to return, max is 50
* 'start' => int The start offset for search results
* 'language' => lang The target document language to match
* 'type' => (all|any|phrase) How the query should be parsed
* 'site' => string A site to which your search should be restricted
* 'format' => (any|html|msword|pdf|ppt|rss|txt|xls)
* 'adult_ok' => bool permit 'adult' content in the search results
* 'similar_ok' => bool permit similar results in the result set
* 'country' => string The country code for the content searched
* 'license' => (any|cc_any|cc_commercial|cc_modifiable) The license of content being searched
* 'region' => The regional search engine on which the service performs the search. default us.
*
* @param string $query the query being run
* @param array $options any optional parameters
* @return Zend_Service_Yahoo_WebResultSet The return set
* @throws Zend\Service\Exception
*/
public function webSearch($query, array $options = array())
{
static $defaultOptions = array('type' => 'all',
'start' => 1,
'results' => 10,
'format' => 'any');
$options = $this->_prepareOptions($query, $options, $defaultOptions);
$this->_validateWebSearch($options);
$this->_rest->getHttpClient()->resetParameters();
$this->_rest->setUri('http://search.yahooapis.com');
$response = $this->_rest->restGet('/WebSearchService/V1/webSearch', $options);
if ($response->isError()) {
throw new Zend\Service\Exception('An error occurred sending request. Status code: ' .
$response->getStatus());
}
$dom = new DOMDocument();
$dom->loadXML($response->getBody());
self::_checkErrors($dom);
return new Zend_Service_Yahoo_WebResultSet($dom);
}
开发者ID:niallmccrudden,项目名称:zf2,代码行数:47,代码来源:Yahoo.php
注:本文中的Zend_Rest_Client类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论