Exemplo n.º 1
0
/**
 * Smarty {curl} function plugin
 *
 * Type:     function<br>
 * Name:     curl<br>
 * Purpose:  make http request to a url using curl and return the results.
 *           If method is post, querystring will be removed from end of url
 *           send as post data
 * @param string url
 * @param string method GET or POST
 * @param Smarty
 */
function smarty_function_curl($params, &$smarty)
{
    if (!isset($params['url']) || $params['url'] == '') {
        $smarty->trigger_error("curl_post: missing 'url' parameter");
        return;
    }
    // TODO: add support for GET
    return _curl_post($params['url'], array());
}
Exemplo n.º 2
0
 static function createUser()
 {
     if (!self::checkToken()) {
         return false;
     }
     $header = ['token' => ['Authorization' => 'Bearer ' . self::checkToken()]];
     //随机生成环信用户名和密码
     $user = ['username' => MD5(uniqid()), 'password' => MD5(uniqid())];
     $res = _curl_post(self::$host . '/users', $user, $header);
     if (isset($res['error'])) {
         return false;
     }
     foreach ($res['entities'] as $key => $value) {
         if (!empty($value)) {
             $value['password'] = $user['password'];
             $value['applicationName'] = $res['applicationName'];
             return $value;
         }
     }
     return false;
 }