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


PHP API::Sites方法代码示例

本文整理汇总了PHP中API::Sites方法的典型用法代码示例。如果您正苦于以下问题:PHP API::Sites方法的具体用法?PHP API::Sites怎么用?PHP API::Sites使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在API的用法示例。


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

示例1: PerformTest

 public function PerformTest()
 {
     // Note that API::Sites does NOT return a paged
     // request object, but a derivitave of PagedResponse
     // Enumerate all Stack Exchange sites
     $sites = API::Sites();
     $count = 0;
     // count the sites
     while ($site = $sites->Fetch()) {
         if (!isset($site['name'])) {
             throw new Exception('Site array returned is invalid.');
         }
         ++$count;
     }
     if ($count < 100) {
         throw new Exception('Expected more than 100 Stack Exchange sites.');
     }
     // the StackAuth /users/{GUID}/associated route
     $response = API::AssociatedUsers(1);
     if ($response->Total() < 50) {
         throw new Exception('Expected more than 50 associated accounts - only ' . $response->Total() . ' returned.');
     }
 }
开发者ID:ZackHodari,项目名称:QA_requester,代码行数:23,代码来源:global_test.php

示例2:

<?php

// Simple example that demonstrates listing users from a
// Stack Exchange site. Makes use of the output helper functions.
require_once 'config.php';
require_once '../../src/output_helper.php';
// Generate the site combobox
$combo = OutputHelper::CreateCombobox(API::Sites(), 'site');
$site_html = $combo->FetchMultiple()->SetIndices('name', 'api_site_parameter')->SetCurrentSelection()->GetHTML();
?>
<!DOCTYPE html>
<html>
<head>
  <title>Stack.PHP - User List</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <link rel='stylesheet' type='text/css' href='../common/style.css' />
</head>
<body>
  <form id='form'>
    <div id='site_selector'>
      <b>Select a Stack Exchange site:</b>
      <?php 
echo $site_html;
?>
      <input type="submit" value="Go" />
    </div>
    <?php 
if (isset($_GET['site'])) {
    $site = API::Site($_GET['site']);
    $request = $site->Users();
    if (isset($_GET['sort'])) {
开发者ID:ZackHodari,项目名称:QA_requester,代码行数:31,代码来源:user_list.php

示例3: header

<?php

// Demonstrates how Stack.PHP's data retrieval methods can
// be exposed to other clients, such as JavaScript code.
require_once 'config.php';
// The very first thing we do is output CORS headers
header('Access-Control-Allow-Methods: POST, GET');
header('Access-Control-Allow-Origin: *');
// Retrieve all Stack Exchange sites across all pages.
$response = API::Sites();
// Build an array with the response
$sites = array();
while ($site = $response->Fetch(TRUE)) {
    $sites[] = $site->Data();
}
// Encode the data as JSON
$json = json_encode(array('items' => $sites, 'has_more' => FALSE));
// Output the data according to the parameters specified
if (isset($_GET['callback'])) {
    header('Content-type: application/javascript');
    echo "{$_GET['callback']}({$json});";
} else {
    header('Content-type: application/json');
    echo $json;
}
开发者ID:ZackHodari,项目名称:QA_requester,代码行数:25,代码来源:simple_api.php

示例4: index

 public function index()
 {
     $this->SetPageInfo('Stack Exchange Sites', 'http://stackexchange.com/sites');
     $this->SetViewVariable('response', API::Sites());
 }
开发者ID:nathan-osman,项目名称:Stack-Mobile,代码行数:5,代码来源:sites.php

示例5: stdClass

        $campaign = new stdClass();
    }
    ?>


<li class="type-text" id="container-autoposting_campaign_name">
                    <fieldset class="title">
                        <div class="inner">
                            <label for="autoposting_campaign_name">Campaign name</label>
                            <kbd>Set autoposting campaign name</kbd>                        </div>
                    </fieldset>
                    
                    <fieldset class="data">
                        <div class="inner">
                            <input type="text" name="autoposting_campaign_name" value="<?php 
    echo isset($campaign->campaign_name) ? $campaign->campaign_name : '';
    ?>
" id="autoposting_campaign_name"  />
                        </div>
                    </fieldset>
                    <div class="clear"></div>
                </li>
                

                <li class="type-text" id="container-autoposting_search_term">
                    <fieldset class="title">
                        <div class="inner">
                            <label for="autoposting_search_term">Search Term</label>
                            <kbd>Set search term</kbd>                        </div>
                    </fieldset>
                    
开发者ID:gp6shc,项目名称:aok,代码行数:30,代码来源:stack-autoposting-campaigns_8.php


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