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


PHP api_error函数代码示例

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


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

示例1: api_getMembers_date

function api_getMembers_date($house, $date) {
	if ($date = parse_date($date)) {
		api_getMembers($house, '"' . $date['iso'] . '"');
	} else {
		api_error('Invalid date format');
	}
}
开发者ID:rhaleblian,项目名称:twfy,代码行数:7,代码来源:api_getMembers.php

示例2: api_findArticles_invoke

function api_findArticles_invoke($params)
{
    $search = $params['search'];
    if (!$search) {
        api_error("required parameter 'search' is missing");
        return;
    }
    $start = (int) $params['offset'];
    $num = (int) $params['limit'];
    if (!$num) {
        $num = 100;
    }
    if (!$start) {
        $start = 0;
    }
    try {
        $xap = new XapSearch();
        $xap->set_query($search);
        $results = $xap->run($start, $num, 'date');
        //        foreach( $results as &$a ) {
        //            // convert datetime objects to strings
        //            $a['pubdate'] = $a['pubdate']->format('c');
        //        }
        $output = array('results' => $results);
        api_output($output);
    } catch (Exception $e) {
        api_error($e->getMessage());
    }
}
开发者ID:bcampbell,项目名称:journalisted,代码行数:29,代码来源:api_findArticles.php

示例3: api_getMSP_constituency

function api_getMSP_constituency($constituency)
{
    $output = _api_getMSP_constituency(array($constituency));
    if (!$output) {
        api_error('Unknown constituency, or no MSP for that constituency');
    }
}
开发者ID:leowmjw,项目名称:twfy,代码行数:7,代码来源:api_getMSP.php

示例4: api_getRepresentatives_postcode

function api_getRepresentatives_postcode($pc)
{
    $pc = preg_replace('#[^0-9]#i', '', $pc);
    if (is_postcode($pc)) {
        $constituency = postcode_to_constituency($pc);
        if ($constituency == 'CONNECTION_TIMED_OUT') {
            api_error('Connection timed out');
        } elseif ($constituency) {
            if (is_array($constituency)) {
                $constituencies = $constituency;
            } else {
                $constituencies = array($constituency);
            }
            $output = array();
            foreach ($constituencies as $c) {
                $output[] = _api_getMP_constituency($c);
            }
            api_output($output);
        } else {
            api_error('Unknown postcode');
        }
    } else {
        api_error('Invalid postcode');
    }
}
开发者ID:leowmjw,项目名称:twfy,代码行数:25,代码来源:api_getRepresentatives.php

示例5: api_getDivisions_postcode

function api_getDivisions_postcode($pc)
{
    $pc = preg_replace('#[^0-9]#i', '', $pc);
    $output = array();
    if (is_postcode($pc)) {
        $constituency = postcode_to_constituency($pc);
        if ($constituency == 'CONNECTION_TIMED_OUT') {
            api_error('Connection timed out');
        } elseif ($constituency) {
            if (is_array($constituency)) {
                $constituencies = $constituency;
            } else {
                $constituencies = array($constituency);
            }
            foreach ($constituencies as $c) {
                $output[] = array('name' => html_entity_decode($c));
            }
        } else {
            api_error('Unknown postcode');
        }
    } else {
        api_error('Invalid postcode');
    }
    api_output($output);
}
开发者ID:leowmjw,项目名称:twfy,代码行数:25,代码来源:api_getDivisions.php

示例6: api_getBoundary_name

function api_getBoundary_name($name)
{
    $name = html_entity_decode(normalise_constituency_name($name));
    # XXX
    if (!$name) {
        api_error('Name not recognised');
        return;
    }
    $out = array();
    $areas = _api_cacheCheck('mapit_get_areas_by_type', 'WMC');
    $areas_info = _api_cacheCheck('mapit_get_voting_areas_info', $areas);
    $id = null;
    foreach ($areas_info as $k => $v) {
        if (html_entity_decode(normalise_constituency_name($v['name'])) == $name) {
            $id = $k;
        }
    }
    if (!$id) {
        api_error('No data found for name');
        return;
    }
    $out = mapit_get_voting_area_geometry($id, 'wgs84');
    if (isset($out['polygon'])) {
        api_output($out['polygon']);
    } else {
        api_error('Nothing returned from get_voting_areas_geometry');
    }
}
开发者ID:leowmjw,项目名称:twfy,代码行数:28,代码来源:api_getBoundary.php

示例7: api_getArticles_invoke

function api_getArticles_invoke($params)
{
    $article_ids = array();
    if ($params['id36']) {
        $id36s = preg_split("/[\\s,]+/", $params['id36']);
        foreach ($id36s as $id36) {
            $article_ids[] = article_id36_to_id($id36);
        }
    }
    if ($params['url']) {
        // look up article by its original url
        $url = $params['url'];
        $art_id = article_find($url);
        if (is_null($art_id)) {
            api_error("couldn't find article with url: '" . $url . "'");
            return;
        }
        $article_ids[] = $art_id;
    }
    if (!$article_ids) {
        api_error("No articles specified - use 'id36' and/or 'url'");
        return;
    }
    #$brief = $params['brief'] ? TRUE : FALSE;
    $fields = array('title', 'id36', 'srcorgname', 'iso_pubdate', 'permalink', 'journos', 'description');
    $results = array();
    foreach ($article_ids as $id) {
        $raw = article_collect($id);
        $art = array_cherrypick($raw, $fields);
        $results[] = $art;
    }
    $output = array('status' => 0, 'results' => $results);
    api_output($output);
}
开发者ID:bcampbell,项目名称:journalisted,代码行数:34,代码来源:api_getArticles.php

示例8: api_getJournoArticles_invoke

function api_getJournoArticles_invoke($params)
{
    $offset = (int) $params['offset'];
    $limit = (int) $params['limit'];
    if (!$limit) {
        $limit = 100;
    }
    if (!$offset) {
        $offset = 0;
    }
    $j = $params['journo'];
    if (!$j) {
        api_error("required parameter 'journo' is missing");
        return;
    }
    $jfield = is_numeric($j) ? 'id' : 'ref';
    $sql = <<<EOT
SELECT a.id, a.title, a.srcorg, a.permalink, a.description, a.pubdate
    FROM ((article a INNER JOIN journo_attr attr ON a.id=attr.article_id)
        INNER JOIN journo j ON j.id=attr.journo_id)
    WHERE a.status='a' AND j.status='a' AND j.{$jfield}=?
    ORDER BY a.pubdate DESC
    LIMIT ?
    OFFSET ?
EOT;
    $articles = db_getAll($sql, $j, $limit, $offset);
    foreach ($articles as &$a) {
        $d = new DateTime($a['pubdate']);
        $a['pubdate'] = $d->format('c');
    }
    $output = array('results' => $articles);
    api_output($output);
}
开发者ID:bcampbell,项目名称:journalisted,代码行数:33,代码来源:api_getJournoArticles.php

示例9: api_checkarg_post_required

 function api_checkarg_post_required($arg, $friendly)
 {
     $arg = api_checkarg_post($arg);
     if (empty($arg)) {
         api_error(SN_API_CALL_EMPTY_PARAMETER, sprintf("Field '%s' is required.", $friendly));
     }
     return $arg;
 }
开发者ID:csnxs,项目名称:disciple,代码行数:8,代码来源:apishared.php

示例10: get_package_path

/**
 * Gets the file path for the specified package version. Throws an exception if
 * the package version does not exist.
 */
function get_package_path($id, $version)
{
    if (!DB::validateIdAndVersion($id, $version) || strpos($id, '/') !== false || strpos($version, '/') !== false) {
        api_error('404', 'Package version not found');
    }
    // This is safe - These values have been validated via validateIdAndVersion above
    return '/packagefiles/' . $id . '/' . $version . '.nupkg';
}
开发者ID:makari4cpp,项目名称:simple-nuget-server,代码行数:12,代码来源:core.php

示例11: api_getConstituency_name

function api_getConstituency_name($constituency) {
    $constituency = normalise_constituency_name($constituency);
    if (!$constituency) {
        api_error('Could not find anything with that name');
        return;
    }
    return _api_getConstituency_name($constituency);
}
开发者ID:nallachaitu,项目名称:theyworkforyou,代码行数:8,代码来源:api_getConstituency.php

示例12: array_get

function array_get($array, $key)
{
    global $INVALID_FILE_UPLOAD;
    if (array_key_exists($key, $array)) {
        return $array[$key];
    } else {
        api_error($INVALID_FILE_UPLOAD);
    }
}
开发者ID:adamjdev,项目名称:Mineskull,代码行数:9,代码来源:api_utils.php

示例13: api_getConstituency_name

function api_getConstituency_name($constituency)
{
    $constituency = MySociety\TheyWorkForYou\Utility\Constituencies::normaliseConstituencyName($constituency);
    if (!$constituency) {
        api_error('Could not find anything with that name');
        return;
    }
    return _api_getConstituency_name($constituency);
}
开发者ID:vijo,项目名称:theyworkforyou,代码行数:9,代码来源:api_getConstituency.php

示例14: api_getGeometry_name

function api_getGeometry_name($name)
{
    $out = _api_getGeometry_name($name);
    if ($out) {
        api_output($out);
    } else {
        api_error('Name not recognised');
    }
}
开发者ID:vijo,项目名称:theyworkforyou,代码行数:9,代码来源:api_getGeometry.php

示例15: logout

function logout($req, $hash, $apiId, $sign)
{
    $af = new AccountManager();
    $result = $af->Logout($hash);
    if ($result) {
        return api_response(array('LoggedOut' => $result));
    } else {
        return api_error(ApiErrorCode::AuthAlreadyLoggedOut, 'Account already logged out!');
    }
}
开发者ID:nolka,项目名称:k5,代码行数:10,代码来源:init.php


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