Posts Tagged with get

Displaying 1-10 of 30 results.
Resolved: Odnoklassniki OK api apiok users.getInfo all fields without errors
posted by admin on April 17, 2017
I try to get all allowed fields from user by id, and got some error

{
error_code:100
error_msg:PARAM : Invalid parameter fields value : [accessible,age,allows_anonym_access,allows_messaging_only_for_friends,birthday,blocked,blocks,can_vcall,can_vmail,capabilities,common_friends_count,current_location,current_status,current_status_date,current_status_date_ms,current_status_id,current_status_track_id,email,feed_subscription,first_name,friend,friend_invitation,gender,has_email,has_service_invisible,invited_by_friend,is_activated,last_name,last_online,last_online_ms,location,login,modified_ms,name,notifications_subscription,online,photo_id,pic1024x768,pic128max,pic128x128,pic180min,pic190x190,pic224x224,pic240min,pic288x288,pic320min,pic50x50,pic600x600,pic640x480,pic_1,pic_2,pic_3,pic_4,pic_5,pic_base,pic_full,pic_max,premium,presents,private,ref,registered_date,registered_date_ms,relationship,show_lock,uid,url_chat,url_chat_mobile,url_profile,url_profile_mobile,vip]
error_data:null
}

All fields I got from apiok official page

[{
accessible:Boolean
age:Integer
allows_anonym_access:Boolean
allows_messaging_only_for_friends:Boolean
birthday:String
blocked:Boolean
blocks:Boolean
can_vcall:Boolean
can_vmail:Boolean
capabilities:String
common_friends_count:Integer
current_location:{
altitude:Float
cellId:Integer
city:String
country:String
ipAddress:String
latitude:Float
longitude:Float
}
current_status:String
current_status_date:Date
current_status_date_ms:Long
current_status_id:String
current_status_track_id:String
email:String
feed_subscription:Boolean
first_name:String
friend:Boolean
friend_invitation:Boolean
gender:String
has_email:Boolean
has_service_invisible:Boolean
invited_by_friend:Boolean
is_activated:Boolean
last_name:String
last_online:String
last_online_ms:Long
locale:String
location:{
city:String
country:String
countryCode:String
countryName:String
}
login:String
modified_ms:Long
name:String
notifications_subscription:Boolean
online:String
photo_id:String
pic1024x768:String
pic128max:String
pic128x128:String
pic180min:String
pic190x190:String
pic224x224:String
pic240min:String
pic288x288:String
pic320min:String
pic50x50:String
pic600x600:String
pic640x480:String
pic_1:String
pic_2:String
pic_3:String
pic_4:String
pic_5:String
pic_base:String
pic_full:String
pic_max:String
premium:Boolean
presents:[{}]
private:Boolean
ref:String
registered_date:Date
registered_date_ms:Long
relations:[{}]
relationship:{}
show_lock:Boolean
uid:String
url_chat:String
url_chat_mobile:String
url_profile:String
url_profile_mobile:String
vip:Boolean
}]
Read more
Wiki: Loads a JavaScript file asynchronously with a callback, like jQuery's $.getScript() except without jQuerywiki
posted by admin on April 13, 2017

function j(u, c) {
var h = document.getElementsByTagName('head')[0], s = document.createElement('script');
s.async = true; s.src = u;
s.onload = s.onreadystatechange = function () {
if (!s.readyState || /loaded|complete/.test(s.readyState)) {
s.onload = s.onreadystatechange = null; if (h && s.parentNode) { h.removeChild(s) } s = undefined;
if (c) { c() }
}
};
h.insertBefore(s, h.firstChild);
}
Read more
Wiki: How to make an AJAX call without jQuery with GET and POST?wiki
posted by admin on March 27, 2017
Using the following snippet you can do similar things pretty easily, like this:

ajax.get('/test.php', {foo: 'bar'}, function() {});

Here is the snippet:

var ajax = {};
ajax.x = function () {
if (typeof XMLHttpRequest !== 'undefined') {
return new XMLHttpRequest();
}
var versions = [
"MSXML2.XmlHttp.6.0",
"MSXML2.XmlHttp.5.0",
"MSXML2.XmlHttp.4.0",
"MSXML2.XmlHttp.3.0",
"MSXML2.XmlHttp.2.0",
"Microsoft.XmlHttp"
];

var xhr;
for (var i = 0; i < versions.length; i++) {
try {
xhr = new ActiveXObject(versions[i]);
break;
} catch (e) {
}
}
return xhr;
};

ajax.send = function (url, callback, method, data, async) {
if (async === undefined) {
async = true;
}
var x = ajax.x();
x.open(method, url, async);
x.onreadystatechange = function () {
if (x.readyState == 4) {
callback(x.responseText)
}
};
if (method == 'POST') {
x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
}
x.send(data)
};

ajax.get = function (url, data, callback, async) {
var query = [];
for (var key in data) {
query.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key]));
}
ajax.send(url + (query.length ? '?' + query.join('&') : ''), callback, 'GET', null, async)
};

ajax.post = function (url, data, callback, async) {
var query = [];
for (var key in data) {
query.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key]));
}
ajax.send(url, callback, 'POST', query.join('&'), async)
};
Read more
Wiki: Install Notepad ++ on Ubuntu 16.04wiki
posted by admin on February 28, 2017
To add the PPA, update apt-get and run install - open terminal (Ctrl+Alt+T) and run:

sudo add-apt-repository ppa:notepadqq-team/notepadqq
sudo apt-get update
sudo apt-get install notepadqq
Read more
Resolved: Laravel check database connection
posted by admin on January 24, 2017
How to check database connection status?
.env

DB_CONNECTION=mysql
DB_HOST=localhost
DB_DATABASE=trade100
DB_USERNAME=root
DB_PASSWORD=
Read more
Wiki: CActiveRelation HAS_MANY BELONGS_TO based on secondary keywiki
posted by admin on November 16, 2016
In the Model class, I overrode the getTableSchema and manually defined the foreign keys like so:

public function getTableSchema()
{
$table = parent::getTableSchema();

$table->columns['sid']->isForeignKey = true;
$table->foreignKeys['sid'] = array('Click', 'm_sid');

return $table;
}

And in the corresponding table:

public function getTableSchema()
{
$table = parent::getTableSchema();

$table->columns['m_sid']->isForeignKey = true;
$table->foreignKeys['m_sid'] = array('Message', 'sid');

return $table;
}

Now the standard relation definitions work directly!

'clicks'=>array( self::HAS_MANY, 'Click', 'm_sid' ),

as well as

'message'=>array( self::BELONGS_TO, 'Message', 'sid'),
Read more
Wiki: Yii 1.1 new CDbCriteriawiki
posted by admin on November 7, 2016

// создаем экземпляр класса CDbCriteria
$criteria = new CDbCriteria;
// выбираемые все столбцы из всех таблиц, участвующих в запросе
$criteria->select = '*';
//$criteria->select = array('post.id', 'post.category_id', 'post.user_id', 'post.title', 'user.name');
//$criteria->select = 'post.id, post.category_id, post.user_id, post.title, user.name';
// псевдоним(алиас) для текущей таблицы
$criteria->alias = 'post';
// выбираем только неповторяющиеся строки данных
$criteria->distinct = true;
// задаем условие запроса
$criteria->condition = 'post.is_hide = :is_hide AND post.user_id = :author_id';
// группируем
$criteria->group = 'post.category_id';
// условие для GROUP BY
$criteria->having = 'post.viwed > 100';
// задаем соединение с другой(ими) таблицами
$criteria->join = 'LEFT JOIN users as user ON user.id = post.user_id';
// максимальное количество возвращаемых записей
$criteria->limit = 20;
// смещение, с которого будут возвращаться записи
$criteria->offset = 5;
// сортировки результатов запроса
$criteria->order = 'post.date_create';
// параметры для замены в SQL выражении, для condition
$criteria->params = array(':is_hide'=>0, ':author_id'=>Yii::app()->user->id);
// внешние таблицы должны быть связаны с первичной таблицей в одном SQL-запросе
$criteria->together = true;
// получение связанных объектов в режиме "жадной" загрузки
$criteria->with = array('profile', 'comments', 'category');
// добавляем условие between (диапазон)
$criteria->addBetweenCondition('post.date_update', '09-12-2011', '09-12-2015');
// добавляем условие для сравнения переданного списка со значениями столбцов
$criteria->addColumnCondition(array('status'=>1), 'AND')
// добавляем условие IN к уже имеющемуся (condition)
$criteria->addInCondition('post.category_id', array('6', '24', '247'), 'OR');
// добавляем условие к уже имеющемуся (condition)
$criteria->addCondition("count_comments <= :count_comments");
// сливает критерий с другим
if($_POST['search_text']){
$criteriaSearch = new CDbCriteria();
$criteriaSearch->addSearchCondition('description', $_POST['search_text']. true, 'AND', 'LIKE');
$criteria->mergeWith($criteriaSearch, 'AND');
}
$posts = Post::model()->findAll($criteria);
Read more
Resolved: PHP echo link content in page
posted by admin on October 26, 2016
I am working on website and in locale and want to show in my page part of code from live server.
like

echo PHP_LINK_READER_FUNCTION("SOME_URL");
Read more
Resolved: PHP datetime to russian user friendly format converting. Дата и время на русский на дружественный вид
posted by admin on October 12, 2016
I have datetime from databse MySQL, in format
2016-10-10 12:34:33

By PHP datetime formats I can have string like this
07 October 2016, 04:11, Friday

But I want the3 same output, but in russian
07 Октября 2016, 04:11, ПятницаRead more
Wiki: Yii 1.1: How to work with flash messageswiki
posted by admin on May 22, 2016
Summary
Set your messages in a controller:

Yii::app()->user->setFlash('success', "Data1 saved!");
Yii::app()->user->setFlash('error', "Data2 failed!");
Yii::app()->user->setFlash('notice', "Data3 ignored.");

Display them in your view:

<?php
foreach(Yii::app()->user->getFlashes() as $key => $message) {
echo '<div class="flash-' . $key . '">' . $message . "</div>\n";
}
?>

Setting flash messages
A flash message is used in order to keep a message in session through one or several requests of the same user. By default, it is removed from session after it has been displayed to the user. Flash messages are usually used in combination with HTTP redirections, because in this case there is no view, so messages can only be displayed in the request that follows redirection.

A flash message has a name and a content (AKA key and value). It is an entry of an associative array. The name is a string: often "notice", "success", or "error", but it can be anything. The content is usually a string. You can put HTML tags in your message if you display it raw. You can also set the message value to a number or an array: it will be serialized and kept in session like a string.

Flash messages can be set using the setFlash() Method of CWebUser. For example, if you would like to inform the user that his changes were successfully saved, you could add the following line to your Controller:

<?php
Yii::app()->user->setFlash('success', "Data saved!");
$this->redirect(array('thing/view', 'id' => 1));

In this example we used the key 'success'. If you want to define more than one flash messages, you will have to use different keys.
Displaying flash messages
To check for flash messages we use the hasFlash() Method and to obtain the flash message we use the getFlash() Method. Since Yii v1.1.3, there is also a method getFlashes() to fetch all the messages.

By default, fetching a message deletes it from the session. This means that a message is meant to be displayed only on the first page served to the user. The fetching methods have a boolean parameter that can change this behavior. See the API links in the previous paragraph.

Displaying statically
So showing of the flash message defined above in a view is done by

<?php if(Yii::app()->user->hasFlash('success')):?>
<div class="info">
<?php echo Yii::app()->user->getFlash('success'); ?>
</div>
<?php endif; ?>

These few lines of code will make a flash message with the key "success" visible to the user within a div of class "info". The message will be displayed until this or another page is (re)loaded in the browser.

If you want to always display all the flash messages, then you should add a block to your layout (by default protected/views/layout/main.php). Here is a more elaborate example:

<?php
$flashMessages = Yii::app()->user->getFlashes();
if ($flashMessages) {
echo '<ul class="flashes">';
foreach($flashMessages as $key => $message) {
echo '<li><div class="flash-' . $key . '">' . $message . "</div></li>\n";
}
echo '</ul>';
}
?>

The default CSS created by the Yii script yiic webapp has directives for three classes of flash messages on a div tag: flash-error, flash-notice, flash-success.

The best way to know if some flash messages are set is to check if Yii::app()->user->getFlashes() is empty. Since v1.1.7, Yii keeps an associative array of the flash keys in the form array("key1" => 0, ...), or null if not flash message is set. You can fetch this with Yii::app()->user->getState(CWebUser::FLASH_COUNTERS) but this is not recommended, as Yii could change this internal process.

Displaying dynamically (with Javascript)
If you want the flash message to appear somewhere above the content and then automatically fade out after a few seconds, you will have to add the following lines to your view:

<?php
Yii::app()->clientScript->registerScript(
'myHideEffect',
'$(".info").animate({opacity: 1.0}, 3000).fadeOut("slow");',
CClientScript::POS_READY
);
?>

With these lines of code we register a piece of jQuery (already included with YII) javascript code, using 'myHideEffect' as ID. It will be inserted in the jQuery's ready function (CClientScript::POS_READY). Due to the chainablity of jQuery the little script will run two effects on the .info DIV sequentially:

.animate({opacity: 1.0}, 3000)

Normally this would animate the .info DIV to a full opacity within 3 seconds. But the DIV is already rendered with full opacity upon page load, so calling this effect will just cause a delay for 3 seconds.

.fadeOut("slow")

This is the fadeOut effect which will hide the .info DIV at slow speed.Read more