本文整理汇总了PHP中Zend_Service_Delicious类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Service_Delicious类的具体用法?PHP Zend_Service_Delicious怎么用?PHP Zend_Service_Delicious使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Service_Delicious类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: publishToDelicious
function publishToDelicious($title, $url, $note, $tags = array())
{
if (DELICIOUS_PUB) {
/* Setup Zend */
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Service_Delicious');
$delicious = new Zend_Service_Delicious(DELICIOUS_USER, DELICIOUS_PASS);
$delicious->createNewPost($title, $url)->setNotes($note)->setTags($tags)->save();
}
}
开发者ID:nickavv,项目名称:iSENSE,代码行数:10,代码来源:social.php
示例2: save
/**
* Saves post
*/
public function save()
{
$parms = array('url' => $this->_url, 'description' => $this->_title, 'extended' => $this->_notes, 'shared' => $this->_shared ? 'yes' : 'no', 'tags' => implode(' ', (array) $this->_tags), 'replace' => 'yes');
if ($this->_date instanceof Zend_Date) {
$parms['dt'] = $this->_date->get('Y-m-d\\TH:i:s\\Z');
}
return $this->_service->makeRequest(Zend_Service_Delicious::PATH_POSTS_ADD, $parms);
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:11,代码来源:Post.php
示例3: fetch
public function fetch()
{
if ($this->_disabled) {
return array();
}
$frontendOptions = array('lifetime' => $this->_config->cacheLifetime, 'automatic_serialization' => true);
$backendOptions = array('cache_dir' => $this->_config->cacheDir);
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
if (!($this->_items = $cache->load('delicious'))) {
$delicious = new Zend_Service_Delicious($this->_config->username, $this->_config->password);
$results = $delicious->getRecentPosts(null, $this->_config->limit);
$this->_items = array();
foreach ($results as $entry) {
$this->_items[] = new Polycast_Stalker_Item_Delicious($entry->getTitle(), $entry->getUrl(), $entry->getTags(), new DateTime($entry->getDate()->toString()), $entry->getNotes(), $this->_config->items);
}
$cache->save($this->_items, 'delicious');
uasort($this->_items, array('Polycast_Stalker', 'sortItems'));
$this->_items = array_slice($this->_items, 0, $this->_config->limit, true);
}
return count($this->_items);
}
开发者ID:polycaster,项目名称:Polycast_Stalker,代码行数:21,代码来源:Delicious.php
示例4: testGetPosts
/**
* @return void
*/
public function testGetPosts()
{
$posts = $this->_delicious->getUserPosts(self::TEST_UNAME, 10);
$this->assertType('Zend_Service_Delicious_PostList', $posts);
// check if all objects in returned Zend_Service_Delicious_PostList
// are instances of Zend_Service_Delicious_SimplePost
foreach ($posts as $post) {
$this->assertType('Zend_Service_Delicious_SimplePost', $post);
}
// test filtering of Zend_Service_Delicious_PostList by tag name
$filterPostList = $posts->withTag('zfSite');
foreach ($filterPostList as $post) {
$this->assertType('array', $post->getTags());
$this->assertContains('zfSite', $post->getTags());
}
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:19,代码来源:PublicDataTest.php
示例5: makeRequest
/**
* Handles all GET requests to a web service
*
* @param string $path Path
* @param array $parms Array of GET parameters
* @param string $type Type of a request ("xml"|"json")
* @return mixed decoded response from web service
*/
public function makeRequest($path, array $parms = array(), $type = 'xml')
{
// if previous request was made less then 1 sec ago
// wait until we can make a new request
$timeDiff = microtime(true) - self::$_lastRequestTime;
if ($timeDiff < 1) {
usleep((1 - $timeDiff) * 1000000);
}
$this->_rest->getHttpClient()->setAuth($this->_authUname, $this->_authPass);
switch ($type) {
case 'xml':
$this->_rest->setUri(self::API_URI);
break;
case 'json':
$parms['raw'] = true;
$this->_rest->setUri(self::JSON_URI);
break;
default:
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception('Unknown request type');
}
self::$_lastRequestTime = microtime(true);
$response = $this->_rest->restGet($path, $parms);
if (!$response->isSuccessful()) {
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception("Http client reported an error: '{$response->getMessage()}'");
}
$responseBody = $response->getBody();
switch ($type) {
case 'xml':
$dom = new DOMDocument() ;
if (!@$dom->loadXML($responseBody)) {
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception('XML Error');
}
return $dom;
case 'json':
return Zend_Json_Decoder::decode($responseBody);
}
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:65,代码来源:Delicious.php
示例6: die
$p->vxContainer('add_sync', $sync);
break;
}
case 'add_sync_start':
if (!$p->User->vxIsLogin()) {
die($p->URL->vxToRedirect($p->URL->vxGetLogin($p->URL->vxGetAddSync())));
break;
} else {
$sync = array();
$sync['status'] = 'default';
if (isset($_POST['d_u']) && isset($_POST['d_p'])) {
$del_user = fetch_single($_POST['d_u']);
$del_pass = fetch_single($_POST['d_p']);
if ($del_user != '' && $del_pass != '') {
require_once 'Zend/Service/Delicious.php';
$del = new Zend_Service_Delicious($del_user, $del_pass);
try {
$posts = $del->getAllPosts();
} catch (Zend_Service_Delicious_Exception $e) {
$posts = false;
$sync['status'] = 'error';
}
if ($posts) {
var_dump($posts);
$result = Add::vxSync($p->User, $p->db, $posts);
var_dump($result);
}
} else {
$sync['status'] = 'default';
}
} else {
开发者ID:biaodianfu,项目名称:project-babel,代码行数:31,代码来源:babel.php
示例7: makeRequest
/**
* Handles all GET requests to a web service
*
* @param string $path Path
* @param array $parms Array of GET parameters
* @param string $type Type of a request xml|json
* @return DOMDocument response from web service
*/
public function makeRequest($path, $parms = array(), $type = 'xml')
{
settype($parms, 'array');
// if previous request was made less then 1 sec ago
// wait until we can make a new request
$timeDiff = microtime(true) - self::$_lastRequestTime;
if ($timeDiff < 1) {
usleep((1 - $timeDiff) * 1000000);
}
$this->_http->resetParameters();
foreach ($parms as $f_parm => $f_value) {
$this->_http->setParameterGet($f_parm, $f_value);
}
switch ($type) {
case 'xml':
$this->_http->setUri(self::API_URI . $path);
break;
case 'json':
$this->_http->setUri(self::JSON_URI . $path);
$this->_http->setParameterGet('raw', true);
break;
default:
throw new Zend_Service_Delicious_Exception('Unknown request type');
}
self::$_lastRequestTime = microtime(true);
$response = $this->_http->request(Zend_Http_Client::GET);
if (!$response->isSuccessful()) {
throw new Zend_Service_Delicious_Exception("Http client reported an error: '{$response->getMessage()}'");
}
$responseBody = $response->getBody();
switch ($type) {
case 'xml':
$dom = new DOMDocument();
if (!@$dom->loadXML($responseBody)) {
throw new Zend_Service_Delicious_Exception('XML Error');
}
return $dom;
case 'json':
return Zend_Json::decode($responseBody);
}
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:49,代码来源:Delicious.php
示例8: get_user_posts_by_tag
/**
* For an individual tag
*
* @param string $user
* @param string $count
* @param string $tag
* @return void
* @author Dan Chadwick
*/
private function get_user_posts_by_tag($user, $count, $tag)
{
$links = array();
$delicious = new Zend_Service_Delicious();
try {
$posts = $delicious->getUserPosts($user, $count, $tag);
foreach ($posts as $post) {
$links[] = array('title' => $post->getTitle(), 'url' => $post->getUrl());
}
return $links;
} catch (Exception $e) {
Kohana::log('debug', 'Delicious err.' . $e->getMessage());
}
}
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:23,代码来源:delicious.php
示例9: testGetUrlDetails
/**
* Try to get details of some URL
*
* @return void
*/
public function testGetUrlDetails()
{
$details = $this->_delicious->getUrlDetails(self::TEST_URL);
$this->assertType('array', $details);
$this->assertArrayHasKey('hash', $details);
$this->assertArrayHasKey('top_tags', $details);
$this->assertArrayHasKey('url', $details);
$this->assertArrayHasKey('total_posts', $details);
$this->assertEquals(self::TEST_URL, $details['url']);
$this->assertType('array', $details['top_tags']);
}
开发者ID:travisj,项目名称:zf,代码行数:16,代码来源:PublicDataTest.php
示例10: testDates
/**
*
* @return void
*/
public function testDates()
{
$this->assertType('array', $this->_delicious->getDates());
}
开发者ID:travisj,项目名称:zf,代码行数:8,代码来源:PrivateDataTest.php
示例11: testDates
/**
*
* @return void
*/
public function testDates()
{
$this->assertTrue(is_array($this->_delicious->getDates()));
}
开发者ID:jsnshrmn,项目名称:Suma,代码行数:8,代码来源:PrivateDataTest.php
示例12: save
/**
* Saves post
*
* @return DOMDocument
*/
public function save()
{
$parms = array('url' => $this->_url, 'description' => $this->_title, 'extended' => $this->_notes, 'shared' => $this->shared ? 'yes' : 'no', 'tags' => implode(' ', (array) $this->_tags), 'replace' => 'yes');
return $this->service->makeRequest(Delicious::PATH_POSTS_ADD, $parms);
}
开发者ID:robertodormepoco,项目名称:zf2,代码行数:10,代码来源:Post.php
注:本文中的Zend_Service_Delicious类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论