小编Doz*_*ent的帖子

"PKIX路径构建失败"和"无法找到请求目标的有效证书路径"

我正在尝试使用twitter4j库为我的java项目发送推文.在我第一次运行时,我收到了关于证书sun.security.validator.ValidatorException和错误的错误sun.security.provider.certpath.SunCertPathBuilderException.然后我添加了twitter证书:

C:\Program Files\Java\jdk1.7.0_45\jre\lib\security>keytool -importcert -trustcacerts -file PathToCert -alias ca_alias -keystore "C:\Program Files\Java\jdk1.7.0_45\jre\lib\security\cacerts"
Run Code Online (Sandbox Code Playgroud)

但没有成功.这是获得twitters的过程:

public static void main(String[] args) throws TwitterException {
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true)
        .setOAuthConsumerKey("myConsumerKey")
        .setOAuthConsumerSecret("myConsumerSecret")
        .setOAuthAccessToken("myAccessToken")
        .setOAuthAccessTokenSecret("myAccessTokenSecret");

    TwitterFactory tf = new TwitterFactory(cb.build());
    Twitter twitter = tf.getInstance();

    try {
        Query query = new Query("iphone");
        QueryResult result;
        result = twitter.search(query);
        System.out.println("Total amount of tweets: " + result.getTweets().size());
        List<Status> tweets = result.getTweets();

        for (Status tweet : tweets) {
            System.out.println("@" + tweet.getUser().getScreenName() + " …
Run Code Online (Sandbox Code Playgroud)

java jsp servlets twitter4j

350
推荐指数
18
解决办法
99万
查看次数

错误:UNABLE_TO_VERIFY_LEAF_SIGNATURE Phonegap安装

我正在尝试在Ubuntu中安装Phonegap.NodeJS的安装很成功,但我无法安装Phonegap本身.这是终端的错误输出:

test@test-VirtualBox:~$ sudo npm install -g phonegap
npm http GET https://registry.npmjs.org/phonegap
npm http GET https://registry.npmjs.org/phonegap
npm http GET https://registry.npmjs.org/phonegap
npm ERR! Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm ERR!     at SecurePair.<anonymous> (tls.js:1350:32)
npm ERR!     at SecurePair.EventEmitter.emit (events.js:92:17)
npm ERR!     at SecurePair.maybeInitFinished (tls.js:963:10)
npm ERR!     at CleartextStream.read [as _read] (tls.js:463:15)
npm ERR!     at CleartextStream.Readable.read (_stream_readable.js:320:10)
npm ERR!     at EncryptedStream.write [as _write] (tls.js:366:25)
npm ERR!     at doWrite (_stream_writable.js:219:10)
npm ERR!     at writeOrBuffer (_stream_writable.js:209:5)
npm ERR!     at EncryptedStream.Writable.write (_stream_writable.js:180:11)
npm ERR!     at write (_stream_readable.js:573:24)
npm ERR! If …
Run Code Online (Sandbox Code Playgroud)

node.js npm cordova ubuntu-13.10

53
推荐指数
3
解决办法
7万
查看次数

是否可以onclick ="history.clear();"

我将在我的PhoneGap应用程序中实现注销按钮,该应用程序将用户返回到认证页面(带有已清除的字段).对于按钮我正在使用onclick事件的锚点:

<script type="text/javascript">
function doLogout() {
    var backlen = history.length;
    history.go(-backlen);
    window.location.replace("index.html");
}
</script>

<a data-role="none" href="#" onclick="doLogout"></a>
Run Code Online (Sandbox Code Playgroud)

但它不起作用,即它只是让我回到已经填充的文件的认证页面,似乎只是后退一步.我不确定history.clear(),因为谷歌搜索它没有给我任何东西:

<a data-role="none" href="index.html" onclick="javascript:history.clear();"></a>
Run Code Online (Sandbox Code Playgroud)

谁能告诉我我的问题在哪里?如果有其他解决方案来处理PhoneGap中的注销事件,我会遵循它.谢谢

javascript logout cordova

11
推荐指数
2
解决办法
6万
查看次数

通过使用PHP中的参数调用URL来获取JSON对象

我想通过调用moodle url来获取json数据:

https://<moodledomain>/login/token.php?username=test1&password=Test1&service=moodle_mobile_app
Run Code Online (Sandbox Code Playgroud)

moodle系统的响应格式如下:

{"token":"a2063623aa3244a19101e28644ad3004"}
Run Code Online (Sandbox Code Playgroud)

我试图用PHP处理的结果:

if ( isset($_POST['username']) && isset($_POST['password']) ){

                 // test1                        Test1

    // request for a 'token' via moodle url
    $json_url = "https://<moodledomain>/login/token.php?username=".$_POST['username']."&password=".$_POST['password']."&service=moodle_mobile_app";

    $obj = json_decode($json_url);
    print $obj->{'token'};         // should print the value of 'token'

} else {
    echo "Username or Password was wrong, please try again!";
}
Run Code Online (Sandbox Code Playgroud)

结果是:未定义

现在的问题是: 如何处理moodle系统的json响应格式?任何想法都会很棒.

[更新]: 我通过curl使用了另一种方法,并在php.ini中更改了以下行:*extension = php_openssl.dll*,*allow_url_include = On*,但现在出现错误:注意:尝试获取非属性宾语.这是更新的代码:

function curl($url){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, …
Run Code Online (Sandbox Code Playgroud)

php json moodle

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

PhoneGap - 从当前应用程序启动其他应用程序

我正在为Android开发一个基于phonegap的应用程序,并想知道如何运行另一个应用程序,甚至在当前设备中未安装所需的应用程序时进入Android市场.

任何帮助,将不胜感激.

android android-intent cordova

6
推荐指数
1
解决办法
5435
查看次数

JavaScript:禁用&lt;button&gt;直到选择了值

我正在尝试为html5表单实现一个javascript代码,该代码将负责禁用/启用按钮,直到未选择select元素。这是代码:

HTML:

<form name="courseForm" id="courseForm">
    <select name="coursetype" id="coursetype" onchange="enableStartBtn()">
        <option value="0" selected="selected">Select here...</option>
        <option value="1">CourseName 1</option>
        <option value="2">CourseName 2</option>
        <option value="3">CourseName 3</option>
    </select>
<button type="button" id="startBtn" disabled="disabled" onclick="Test()">Start</button>
</form>
Run Code Online (Sandbox Code Playgroud)

JavaScript

function enableStartBtn() {
    $('#startBtn').removeAttr('disabled');
}

function Test() {
    var form = $('#courseForm');
    var course = $('#coursetype', form).val();
    if (course == '0') {
        alert('Select the course first!');
    } else if (course == '1') {
        alert('CourseName 1 is selected!');
    } else if (course == '2') {
        alert('CourseName 2 is selected!'); …
Run Code Online (Sandbox Code Playgroud)

javascript jquery html5 button selection

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

根据java中的索引名称对<String>进行排序

我需要根据特定的索引名称对Set数据进行排序.我有以下数据:

txt_4: somevalue
txt_2: somevalue
txt_1: somevalue
txt_0: somevalue
txt_3: somevalue
Run Code Online (Sandbox Code Playgroud)

我该如何对这些数据进行排序?谢谢.

更新:

排序后的预期数据:

txt_0: somevalue
txt_1: somevalue
txt_2: somevalue
txt_3: somevalue
txt_4: somevalue
Run Code Online (Sandbox Code Playgroud)

java sorting set

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

SQL 获取每个 ID 的最新记录

我有三个包含数据的表,如下所示:

用户

Id   Name     Other_Columns
---------------------------
1    John     Blah
2    Ricky    Blah
3    Stella   Blah
4    Bob      Blah
Run Code Online (Sandbox Code Playgroud)

萨尔多

Id   User_id   Saldo
--------------------
1    3         0.00
2    1         9.00
3    2         0.15
4    4         3.50
Run Code Online (Sandbox Code Playgroud)

付款

Id   User_id   Amount     Paid_date
------------------------------------------
1    2         10.00      2014-09-01 08:10
2    2         25.00      2014-09-01 09:00
3    3         100.00     2014-05-10 12:47
4    1         20.50      2014-02-23 15:30
Run Code Online (Sandbox Code Playgroud)

如何得到这样的结果:

Id   Name     Saldo     Last Payment
------------------------------------------
1    John     9.00      23.02.2014 20.50
2    Ricky    0.15      01.09.2014 25.00
3    Stella …
Run Code Online (Sandbox Code Playgroud)

sql sql-server multiple-tables

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