小编Exp*_* be的帖子

获取Google API令牌

我需要获取谷歌有效令牌才能使用Google API,但我的代码不起作用.你能告诉我一下吗?

$client_id = '495225261106.apps.googleusercontent.com';
$client_secret = urlencode('MY_SECRET_CDE');
$redirect_uri = urlencode('http://MYPAGE.net/test.php');
//$grant_type = urlencode('authorization_code'); //it does not work either.
$grant_type = 'authorization_code';

$post_string = "code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp6&client_id={$client_id}&client_secret={$client_secret}&redirect_uri={$redirect_uri}&grant_type={$grant_type}";

//echo_key_value('post_string',$post_string);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://accounts.google.com/o/oauth2/token');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($ch);   // Execute the HTTP command
$errmsg = curl_error($ch); 

if($errmsg) echo $errmsg;
Run Code Online (Sandbox Code Playgroud)

// 输出: {"error":"invalid_grant"} //

谢谢!

token oauth-2.0

5
推荐指数
1
解决办法
8729
查看次数

Extjs 4.0.7,编辑网格 - 如何获取更新的单元格值?

我需要在控制器中获取(检索)更新的单元格值.(MVC)

所以我试过这个,

var modified = this.getItemGrid().getStore().getUpdatedRecords();
console.log(modified); // return [] empty array

var modified = this.getItemList_Store().getUpdatedRecords();
console.log(modified); // return [] empty array
Run Code Online (Sandbox Code Playgroud)

但总是它返回空数组,即使我更新了一些单元格值.

谁知道我做错了什么?

这是我查看代码的一部分,

Ext.define("App.view.orders.ItemList_view", {
    extend: "Ext.grid.Panel",
    alias: "widget.itemList_view",
    plugins: [
            Ext.create('Ext.grid.plugin.CellEditing', {
                clicksToEdit: 1
            })
    ],
    initComponent: function () {
        this.store = "ItemList_store";
        this.columns = [
            {
                xtype: 'checkcolumn', text: "Ship", width: 50, dataIndex: "DR"
            },
            { header: "test", width: 100, dataIndex: "test",
                editor: {
                    xtype : 'textfield'
                }
            }
        ];

        this.selModel = Ext.create("Ext.selection.CheckboxModel");
        //this.selModel = Ext.create("Ext.selection.CellModel"); …
Run Code Online (Sandbox Code Playgroud)

grid extjs extjs4

5
推荐指数
1
解决办法
2万
查看次数

Extjs4.1,在存储同步后检索响应消息

如何在失败功能中检索响应消息?

store.sync({
 success : function(){},
 failure : function(response, options){
   console.log(response.responseText); //it does not work, because there is responseText attr in response
 }  
});
Run Code Online (Sandbox Code Playgroud)

响应文本是这样的,

{"success":false,"message":"Test Error"}
Run Code Online (Sandbox Code Playgroud)

有人知道,请指教.

谢谢

[编辑]

console.log(response); 
Run Code Online (Sandbox Code Playgroud)

然后,

在此输入图像描述

extjs4.1

5
推荐指数
1
解决办法
8111
查看次数

如何为Kotlin和Android设置Mockito

我想使用Mockito进行单元测试,所以我将Mockito库添加到我的gradle依赖项中.

testImplementation 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.12.0' 
Run Code Online (Sandbox Code Playgroud)

但是,我仍然不能使用任何Mockito注释.

/androidTest/ExampleTest.kt

@RunWith(MockitoJUnitRunner::class) // Unresolved reference MockitoJUnitRunner
@Mock // Unresolved reference Mock
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

android mockito kotlin

5
推荐指数
1
解决办法
2899
查看次数

Android,崩溃报告不存在或不是目录

我可以在调试控制台中看到以下警告

W / cr_CrashFileManager:/data/user/0/com.test/cache/WebView/Crash报告不存在或不是目录

我需要自己创建文件夹吗?如何解决警告?

android

5
推荐指数
0
解决办法
805
查看次数

输入元素上的 onClick 与 onFocus

为了在用户单击输入框时将焦点移到输入的末尾,我使用了这样的方法,

$(function() {
    $('#test-input').on('click', function(evt) {
    $target = $(evt.target);
    var val = $target.val();

    $target.val('').val(val);
  });
}())
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<input type="text" name="test" id="test-input" value="abcdefgh" />
Run Code Online (Sandbox Code Playgroud)

但是,如果我将“点击”更改为“焦点”,则不起作用。

$(function() {
    $('#test-input').on('focus', function(evt) {
    $target = $(evt.target);
    var val = $target.val();

    $target.val('').val(val);
  });
}())
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<input type="text" name="test" id="test-input" value="abcdefgh" />
Run Code Online (Sandbox Code Playgroud)

在这种情况下,onClick 和 onFocus 操作有何不同?

html javascript jquery

5
推荐指数
1
解决办法
8024
查看次数

Android popBackStackImmediate 无法移除 Glide 的 SupportRequestManagerFragment

activity.supportFragmentManager.popBackStackImmediate()
Run Code Online (Sandbox Code Playgroud)

popBackStackImmediate 无法移除 Glide 的 SupportRequestManagerFragment,你知道为什么吗?还有其他方法可以从片段堆栈中删除 SupportRequestManagerFragment 吗?

android kotlin android-glide

5
推荐指数
2
解决办法
1424
查看次数

骨干采集比较器

我正在使用骨干和牵线木偶,

我想对我的收藏和渲染视图进行排序.

但奇怪的是发生了什么.

'/ api/note/getList',它返回(并在视图初始化集合时调用它)

[{"id":22,"name":"Test2","isPublic":1},{"id":11,"name":"Test1","isPublic":1},{"id":33,"name":"Test3","isPublic":1}]
Run Code Online (Sandbox Code Playgroud)

这是我的收藏,

define [
    'models/Note'
],
(Note) ->
    class NoteCollection extends Backbone.Collection

        model : Note
        url : '/api/note/getList'

        comparator : (item) =>
            console.log item.get 'id'
            return item.get 'id'
Run Code Online (Sandbox Code Playgroud)

和console.log打印

22
22
11
Run Code Online (Sandbox Code Playgroud)

打印'22'两次?它也没有排序.

我该如何对集合进行排序?

[编辑]

这是初始化集合的compisteView

define [    
    'hbs!./noteCollection_tpl'
    './noteItemView'
    'collections/NoteCollection'
],
(noteCollection_tpl, noteItemView, NoteCollection) ->
    class NoteCollectionView extends Backbone.Marionette.CompositeView
        template : noteCollection_tpl
        itemView : noteItemView
        itemViewContainer : '.noteListContainer'
        className : 'noteWrap'

        initialize : (options) ->
            @collection = new NoteCollection() 
Run Code Online (Sandbox Code Playgroud)

@collection = new NoteCollection()=>我觉得这个运行自动获取.

coffeescript backbone.js

4
推荐指数
1
解决办法
4258
查看次数

Asp.net数据库迁移,什么是Down方法?

当我添加迁移时,会生成Up和Down方法.

我知道当我更新数据库(更新数据库)时,它会运行Up方法.

Down方法怎么样?

何时运行,是否可以回滚?而且,我该怎么办呢?

database-migration asp.net-mvc-4

4
推荐指数
1
解决办法
2257
查看次数

Kotlin 协程 CalledFromWrongThreadException

我正在尝试使用 Kotlin 协程在后台运行一些繁重的工作。

但我收到此错误消息,

“android.view.ViewRootImpl$CalledFromWrongThreadException:只有创建视图层次结构的原始线程才能触摸其视图。”

fun setList() {
    media_image_list.adapter = imageListAdapter
    ...

    launch {
        val images = getImages(galleryPath)
        imageListAdapter.setItems(images)
    }
}




suspend private fun getImages(): MutableList<Image> {
    val uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI
    ...
}
Run Code Online (Sandbox Code Playgroud)

如何让它在后台正确运行?

android coroutine kotlin

4
推荐指数
1
解决办法
6464
查看次数