当前位置: 首页>>代码示例>>PHP>>正文


PHP Core\Webservice类代码示例

本文整理汇总了PHP中Idno\Core\Webservice的典型用法代码示例。如果您正苦于以下问题:PHP Webservice类的具体用法?PHP Webservice怎么用?PHP Webservice使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Webservice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postContent

 function postContent()
 {
     $this->adminGatekeeper();
     $request = $this->getInput('request');
     $key = $this->getInput('key');
     $username = $this->getInput('username');
     $json = $this->getInput('json');
     $follow_redirects = $this->getInput('follow_redirects');
     $method = $this->getInput('method', 'GET');
     $url = \Idno\Core\Idno::site()->config()->getURL();
     if (strripos($url, '/') == strlen($url) - 1) {
         $url = substr($url, 0, strlen($url) - 1);
     }
     $url .= $request;
     $client = new Webservice();
     if ($method == 'POST') {
         $result = $client->post($url, $json, array('X-KNOWN-USERNAME: ' . $username, 'X-KNOWN-SIGNATURE: ' . base64_encode(hash_hmac('sha256', $request, $key, true))));
     } else {
         $result = $client->get($url, null, array('X-KNOWN-USERNAME: ' . $username, 'X-KNOWN-SIGNATURE: ' . base64_encode(hash_hmac('sha256', $request, $key, true))));
     }
     $response = Webservice::getLastResponse();
     $sent_request = Webservice::getLastRequest() . $json;
     $api_request = array('request' => $request, 'key' => $key, 'username' => $username, 'json' => $json, 'sent_request' => $sent_request, 'response' => gzencode($response, 9), 'method' => $method);
     \Idno\Core\Idno::site()->session()->set('api_request', $api_request);
     $this->forward(\Idno\Core\Idno::site()->config()->getURL() . 'admin/apitester/');
 }
开发者ID:sintoris,项目名称:Known,代码行数:26,代码来源:Admin.php

示例2: retrieveItems

 /**
  * Get parsed items from this feed
  * @return array|bool
  */
 function retrieveItems()
 {
     $ws = new Webservice();
     if ($content = $ws->get($this->getFeedURL())) {
         return \Idno\Core\site()->reader()->parseFeed($content['content'], $this->getFeedURL());
     }
     return false;
 }
开发者ID:hank,项目名称:Known,代码行数:12,代码来源:Feed.php

示例3: postContent

 function postContent()
 {
     $this->createGatekeeper();
     // Logged-in only please
     $email = $this->getInput('email');
     $message = $this->getInput('message');
     if (!empty($email) && !empty($message)) {
         $web_client = new Webservice();
         $results = $web_client->post('http://withknown.com/vendor-services/feedback/', ['url' => \Idno\Core\site()->config()->getURL(), 'title' => \Idno\Core\site()->config()->getTitle(), 'version' => \Idno\Core\site()->getVersion(), 'public' => \Idno\Core\site()->config()->isPublicSite(), 'hub' => \Idno\Core\site()->config()->known_hub, 'email' => $email, 'message' => $message]);
         \Idno\Core\site()->session()->addMessage("Thanks! We received your feedback.");
     }
     $this->forward(\Idno\Core\site()->config()->getURL() . 'account/settings/feedback/confirm/');
 }
开发者ID:avewrigley,项目名称:idno,代码行数:13,代码来源:Feedback.php

示例4: publish

 /**
  * If this idno installation has a PubSubHubbub hub, send a publish notification to the hub
  * @param string $url
  * @return array
  */
 static function publish($url)
 {
     if ($hub = \Idno\Core\site()->config()->hub) {
         return \Idno\Core\Webservice::post($hub, ['hub.mode' => 'publish', 'hub.url' => $url]);
     }
     return false;
 }
开发者ID:phpsource,项目名称:idno,代码行数:12,代码来源:PubSubHubbub.php

示例5: retrieveItems

 /**
  * Get parsed items from this feed
  * @return array|bool
  */
 function retrieveItems()
 {
     if ($content = Webservice::get($this->getFeedURL())) {
         return \Idno\Core\Idno::site()->reader()->parseFeed($content['content'], $this->getFeedURL());
     }
     return false;
 }
开发者ID:smartboyathome,项目名称:Known,代码行数:11,代码来源:Feed.php

示例6: registerEventHooks

 function registerEventHooks()
 {
     \Idno\Core\site()->events()->addListener('syndicate', function (\Idno\Core\Event $event) {
         $eventdata = $event->data();
         if (!empty($eventdata['object'])) {
             if (!empty(site()->config()->wayback_machine)) {
                 if ($eventdata['object'] instanceof Entity) {
                     if ($eventdata['object']->isPublic()) {
                         Webservice::get('https://web.archive.org/save/' . $eventdata['object']->getDisplayURL());
                     }
                 }
             }
             $content_type = $eventdata['object']->getActivityStreamsObjectType();
             if ($services = \Idno\Core\site()->syndication()->getServices($content_type)) {
                 if ($selected_services = \Idno\Core\site()->currentPage()->getInput('syndication')) {
                     if (!empty($selected_services) && is_array($selected_services)) {
                         foreach ($selected_services as $selected_service) {
                             $event->data()['syndication_account'] = false;
                             if (in_array($selected_service, $services)) {
                                 site()->triggerEvent('post/' . $content_type . '/' . $selected_service, $eventdata);
                             } else {
                                 if ($implied_service = $this->getServiceByAccountString($selected_service)) {
                                     $eventdata['syndication_account'] = $this->getAccountFromAccountString($selected_service);
                                     site()->triggerEvent('post/' . $content_type . '/' . $implied_service, $eventdata);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     });
 }
开发者ID:johnellison,项目名称:90days,代码行数:33,代码来源:Syndication.php

示例7: getContent

 function getContent()
 {
     $this->createGatekeeper();
     $user = \Idno\Core\site()->session()->currentUser();
     $u = $this->getInput('u');
     if ($content = \Idno\Core\Webservice::get($u)['content']) {
         $parser = new \Mf2\Parser($content, $u);
         if ($return = $parser->parse()) {
             if (isset($return['items'])) {
                 $t = \Idno\Core\site()->template();
                 $body = '';
                 $hcard = [];
                 $this->findHcard($return['items'], $hcard);
                 $hcard = $this->removeDuplicateProfiles($hcard);
                 if (!count($hcard)) {
                     throw new \Exception("Sorry, could not find any users on that page, perhaps they need to mark up their profile in <a href=\"http://microformats.org/wiki/microformats-2\">Microformats</a>?");
                 }
                 // TODO: Add a manual way to add the user
                 foreach ($hcard as $card) {
                     $body .= $t->__(['mf2' => $card])->draw('account/settings/following/mf2user');
                 }
                 // List user
                 $t->body = $body;
                 $t->title = 'Found users';
                 $t->drawPage();
             }
         } else {
             throw new \Exception("Sorry, there was a problem parsing the page!");
         }
     } else {
         throw new \Exception("Sorry, {$u} could not be retrieved!");
     }
     // forward back
     $this->forward($_SERVER['HTTP_REFERER']);
 }
开发者ID:avewrigley,项目名称:idno,代码行数:35,代码来源:Bookmarklet.php

示例8: postContent

 function postContent()
 {
     $body = strip_tags($this->getInput('body'));
     $name = strip_tags($this->getInput('name'));
     $url = trim($this->getInput('url'));
     $url2 = trim($this->getInput('url-2'));
     $validator = $this->getInput('validator');
     if (!empty($url2)) {
         $this->deniedContent();
     }
     $this->referrerGatekeeper();
     if (!empty($body) && !empty($name) && !empty($validator)) {
         if ($object = Entity::getByUUID($validator)) {
             if ($url = Webservice::sanitizeURL($url)) {
                 if ($content = Webservice::get($url)) {
                     if ($content['response'] == '200') {
                         $icon = Webmention::getIconFromWebsiteContent($content['content'], $url);
                     }
                 }
             }
             if (empty($icon)) {
                 $bn = hexdec(substr(md5($url), 0, 15));
                 $number = 1 + $bn % 5;
                 $icon = \Idno\Core\site()->config()->url . 'gfx/users/default-' . str_pad($number, 2, '0', STR_PAD_LEFT) . '.png';
             }
             $object->addAnnotation('reply', $name, $url, $icon, $body);
             $this->forward($object->getDisplayURL());
         }
     }
 }
开发者ID:emory,项目名称:Known,代码行数:30,代码来源:Post.php

示例9: getTitleFromURL

 /**
  * Given a URL, returns the page title.
  * @param $Url
  * @return mixed
  */
 function getTitleFromURL($Url)
 {
     $str = \Idno\Core\Webservice::file_get_contents($Url);
     if (strlen($str) > 0) {
         preg_match("/\\<title\\>(.*)\\<\\/title\\>/siu", $str, $title);
         return htmlspecialchars_decode($title[1]);
     }
     return '';
 }
开发者ID:johnellison,项目名称:90days,代码行数:14,代码来源:Like.php

示例10: registerEventHooks

 function registerEventHooks()
 {
     \Idno\Core\site()->syndication()->registerService('webhooks', function () {
         return $this->hasWebhooks();
     }, array('note', 'bookmark', 'event', 'article'));
     if ($this->hasWebhooks()) {
         if (!empty(\Idno\Core\site()->config()->webhook_syndication)) {
             foreach (\Idno\Core\site()->config()->webhook_syndication as $hook) {
                 \Idno\Core\site()->syndication()->registerServiceAccount('webhooks', $hook['url'], $hook['title']);
             }
         }
         if (\Idno\Core\site()->session()->isLoggedIn()) {
             if (!empty(\Idno\Core\site()->session()->currentUser()->webhook_syndication)) {
                 foreach (\Idno\Core\site()->session()->currentUser()->webhook_syndication as $hook) {
                     \Idno\Core\site()->syndication()->registerServiceAccount('webhooks', $hook['url'], $hook['title']);
                 }
             }
         }
     }
     $hook_function = function (\Idno\Core\Event $event) {
         $eventdata = $event->data();
         if ($this->hasWebhooks()) {
             $object = $eventdata['object'];
             if (!empty($object) && $object instanceof Entity && !empty($eventdata['syndication_account'])) {
                 $payload = array();
                 $hook_url = $eventdata['syndication_account'];
                 if ($owner = $object->getOwner()) {
                     $payload['icon_url'] = $owner->getIcon();
                     $payload['username'] = $owner->getHandle();
                 }
                 $payload['content_type'] = $object->getActivityStreamsObjectType();
                 $payload['text'] = $object->getTitle() . ' <' . $object->getURL() . '>';
                 $payload['title'] = $object->getTitle();
                 $client = new Webservice();
                 $client->post($hook_url, json_encode($payload));
             }
         }
     };
     \Idno\Core\site()->addEventHook('post/note/webhooks', $hook_function);
     \Idno\Core\site()->addEventHook('post/article/webhooks', $hook_function);
     \Idno\Core\site()->addEventHook('post/bookmark/webhooks', $hook_function);
     \Idno\Core\site()->addEventHook('post/event/webhooks', $hook_function);
 }
开发者ID:hank,项目名称:Known,代码行数:43,代码来源:Main.php

示例11: getTitleFromURL

 /**
  * Given a URL, returns the page title.
  * @param $Url
  * @return mixed
  */
 function getTitleFromURL($Url)
 {
     $str = \Idno\Core\Webservice::file_get_contents($Url);
     //@file_get_contents($Url);
     if (strlen($str) > 0) {
         preg_match("/\\<title\\>(.*)\\<\\/title\\>/i", $str, $title);
         return $title[1];
     }
     return '';
 }
开发者ID:avewrigley,项目名称:idno,代码行数:15,代码来源:Like.php

示例12: parseTitle

 function parseTitle($url)
 {
     $response = Webservice::get($url);
     if ($response['response'] == 200) {
         $doc = \DOMDocument::loadHTML($response['content']);
         foreach ($doc->getElementsByTagName('title') as $title) {
             return trim($title->textContent);
         }
     }
     return false;
 }
开发者ID:kylewm,项目名称:KnownIndieSyndicate,代码行数:11,代码来源:Add.php

示例13: getAccessToken

 public function getAccessToken($endpointUrl, $grant_type = 'authorization_code', array $parameters)
 {
     if ($parameters['state'] != \Idno\Core\site()->plugins()->get('AppNet')->getState()) {
         throw new \Exception('State value not correct, possible CSRF attempt.');
     }
     unset($parameters['state']);
     $parameters['client_id'] = $this->key;
     $parameters['client_secret'] = $this->secret;
     $parameters['grant_type'] = $grant_type;
     return \Idno\Core\Webservice::post(\IdnoPlugins\AppNet\Main::$TOKEN_ENDPOINT, $parameters);
 }
开发者ID:pierreozoux,项目名称:KnownAppNet,代码行数:11,代码来源:Client.php

示例14: testAuthenticated

 public function testAuthenticated()
 {
     $user = \Tests\KnownTestCase::user();
     $result = \Idno\Core\Webservice::post(\Idno\Core\Idno::site()->config()->url . 'status/edit', ['body' => "Making a nice test post via the api"], ['Accept: application/json', 'X-KNOWN-USERNAME: ' . $user->handle, 'X-KNOWN-SIGNATURE: ' . base64_encode(hash_hmac('sha256', '/status/edit', $user->getAPIkey(), true))]);
     print_r($result);
     $content = json_decode($result['content']);
     $response = $result['response'];
     $this->assertTrue(empty($result['error']));
     $this->assertTrue(!empty($content));
     $this->assertTrue(!empty($content->location));
     $this->assertTrue($response == 200);
 }
开发者ID:smartboyathome,项目名称:Known,代码行数:12,代码来源:BasicAPITest.php

示例15: testUpload

 public function testUpload()
 {
     $user = \Tests\KnownTestCase::user();
     $result = \Idno\Core\Webservice::post(\Idno\Core\Idno::site()->config()->url . 'photo/edit', ['title' => 'A Photo upload', 'body' => "Uploading a pretty picture via the api", 'photo' => \Idno\Core\WebserviceFile::createFromCurlString("@" . dirname(__FILE__) . "/" . self::$file . ";filename=Photo.jpg;type=image/jpeg")], ['Accept: application/json', 'X-KNOWN-USERNAME: ' . $user->handle, 'X-KNOWN-SIGNATURE: ' . base64_encode(hash_hmac('sha256', '/photo/edit', $user->getAPIkey(), true))]);
     print_r($result);
     $content = json_decode($result['content']);
     $response = $result['response'];
     $this->assertTrue(empty($result['error']));
     $this->assertTrue(!empty($content));
     $this->assertTrue(!empty($content->location));
     $this->assertTrue($response == 200);
 }
开发者ID:smartboyathome,项目名称:Known,代码行数:12,代码来源:UploadTest.php


注:本文中的Idno\Core\Webservice类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。