小编use*_*123的帖子

Facebook javascript与localhost域连接

我正在尝试使用javascript创建facebook连接,这会产生以下错误:

应用程序配置不允许使用URL:应用程序的设置不允许使用一个或多个给定的URL.它必须与网站URL或Canvas URL匹配,或者域必须是App域之一的子域.

是否是由于我使用Localhost服务器进行测试?我是否需要购买域名来测试这个或什么?或者我需要在以下代码中进行更改:

我的代码:

<?php
//
// uses the PHP SDK. Download from https://github.com/facebook/php-sdk
include("facebook-php-sdk/src/facebook.php");

//
// from the facebook app page
define('YOUR_APP_ID', '321849981247524');
define('YOUR_APP_SECRET', '49fd00ce6237aff0af08fd8ca25dbc92');

//
// new facebook object to interact with facebook
$facebook = new Facebook(array(
 'appId' => YOUR_APP_ID,
 'secret' => YOUR_APP_SECRET,
));
//
// if user is logged in on facebook and already gave permissions
// to your app, get his data:
$userId = $facebook->getUser();

?>
<html>
<head>
 <style>body { text-align:center; font-size: 40px }</style>
</head> …
Run Code Online (Sandbox Code Playgroud)

facebook facebook-graph-api facebook-javascript-sdk

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

如何将char*数组转换为std :: string

我声明了一个char*数组 char *excluded_string[50] = { 0 };

之后,excluded_string数组的每个元素都会有一个单词.现在我想将它转换为字符串,以便我可以将所有单词分隔为空格.

std::string ss(excluded_string); 给出错误:

`server.cpp:171:32:错误:没有匹配函数来调用'std :: basic_string :: basic_string(char*[50])'和大的棘手的解释!

c++

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

使用ispunct()删除标点符号

ispunct()以这种方式分离单词时效果很好"one, two; three".然后它将删除",;" 并用给定的字符替换.

但是如果以这种方式给出字符串,"ts='TOK_STORE_ID';"那么它将"ts='TOK_STORE_ID';"作为一个单一的标记,或者

"one,one, two;four$three two" 作为三个令牌 1. "one,one" 2. "two;four$three" 3. "two"

是否有任何一个"one,one, two;four$three two"可以被视为"one one two four three two"每个单独的令牌?

编写手动代码如:

for(i=0;i<str.length();i++)
{
  //validating each character
}
Run Code Online (Sandbox Code Playgroud)

当字符串非常长时,此操作将变得非常昂贵.

那么还有其他功能ispunct()吗?或其他什么?

在c中我们这样做来比较每个字符:

  for(i=0;i<str.length();i++)
    {
      if(str[i]==',' || str[i]==",") // Is there any way here to compare with all puctuations in one shot?
        str[i]=" "; //replace with space

    }
Run Code Online (Sandbox Code Playgroud)

在c ++中,这是正确的方法吗?

c c++

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

用空格替换std :: string中的特定字符

以下代码从char数组中正确删除了标点符号:

#include <cctype>
#include <iostream>

int main()
{
    char line[] = "ts='TOK_STORE_ID'; one,one, two;four$three two";
    for (char* c = line; *c; c++)
    {
        if (std::ispunct(*c))
        {
            *c = ' ';
        }
    }
    std::cout << line << std::endl;
}
Run Code Online (Sandbox Code Playgroud)

如果line类型是这样的代码将如何看std::string

c++ string parsing stdstring

3
推荐指数
3
解决办法
3375
查看次数

Getting facebook current session details like user_id in different pages

My main page is index.php. Here I perform user login and then redirected to url.php using ajax request. Now user may move to various pages.

I need current user facebook id on those pages. How can I get it?

login.php

 <script type="text/javascript">
    window.fbAsyncInit = function() {
      FB.init({
        appId: '<?php
        echo $appId;
        ?>',
        cookie: true,
        xfbml: true,
        //  channelUrl: '<?php
        echo $return_url;
        ?>channel.php',
        oauth: true}
             );
    };
    (function() {
      //alert("1");
      var e = document.createElement('script');
      e.async = true;
      e.src = document.location.protocol …
Run Code Online (Sandbox Code Playgroud)

ajax facebook session-variables facebook-javascript-sdk facebook-php-sdk

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

UnicodeDecodeError: 'utf8' 编解码器无法解码位置 1266 中的字节 0xba:起始字节无效

我正在尝试使用 scikit 训练一些文本数据。在其他 PC 上使用相同的代码没有任何错误,但在我的系统上它给出了错误:

File "/root/Desktop/karim/svn/questo-anso/v5/trials/classify/domain_detection_final/test_classifier_temp.py", line 130, in trainClassifier
    X_train = self.vectorizer.fit_transform(self.data_train.data)
  File "/root/Desktop/karim/software/scikit-learn-0.15.1/sklearn/feature_extraction/text.py", line 1270, in fit_transform
    X = super(TfidfVectorizer, self).fit_transform(raw_documents)
  File "/root/Desktop/karim/software/scikit-learn-0.15.1/sklearn/feature_extraction/text.py", line 808, in fit_transform
    vocabulary, X = self._count_vocab(raw_documents, self.fixed_vocabulary)
  File "/root/Desktop/karim/software/scikit-learn-0.15.1/sklearn/feature_extraction/text.py", line 741, in _count_vocab
    for feature in analyze(doc):
  File "/root/Desktop/karim/software/scikit-learn-0.15.1/sklearn/feature_extraction/text.py", line 233, in <lambda>
    tokenize(preprocess(self.decode(doc))), stop_words)
  File "/root/Desktop/karim/software/scikit-learn-0.15.1/sklearn/feature_extraction/text.py", line 111, in decode
    doc = doc.decode(self.encoding, self.decode_error)
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xba …
Run Code Online (Sandbox Code Playgroud)

python utf-8 scikit-learn

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

Scikit学习多层神经网络

根据Scikit提供的文档学习

hidden_layer_sizes : tuple, length = n_layers - 2, default (100,)
Run Code Online (Sandbox Code Playgroud)

我毫不怀疑.

在我的代码中,我配置的是

MLPClassifier(algorithm='l-bfgs', alpha=1e-5, hidden_layer_sizes=(5, 2), random_state=1)
Run Code Online (Sandbox Code Playgroud)

什么做52表明?

我的理解是,5是隐藏层的数量,但那么2是什么?

参考 - http://scikit-learn.org/dev/modules/generated/sklearn.neural_network.MLPClassifier.html#

machine-learning neural-network scikit-learn

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

echo变量'html code'里面的php变量

我有php文件index.php

在这个文件中使用我正在做的html代码:

的index.php

echo '
<div>
<a class="fragment" href="">
<div>';
Run Code Online (Sandbox Code Playgroud)

在href我想把一些PHP变量的值,即$url 如何做?

这是正确的方法吗?

 <a class="fragment" href="<?php echo $url; ?>">
Run Code Online (Sandbox Code Playgroud)

html php

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

php从stdClass对象获取数组值

这是我从页面收集数据的功能.数据存储在数组中,最后我用var_dump()回显它.

数据被捆绑成长度为40的数组.我试图分别获得每个数组值.

当我使用转储时,数组结果如下所示var_dump($root):

object(stdClass)[1]
  public 'items' => 
    array (size=40)
      0 => 
        object(stdClass)[12983]
          public 'comment' => string 'Locanda is great ! Maybe a bit overrated... But I definitely enjoyed my first dinner here! <br><br>Trippa alla romana is so good! My first time eating tripe and the texture wasn&#39;t bad at all plus the sauce was fantastic! <br><br>The leg of lamb was nice, a bit too rare for me but I didn&#39;t specify how I wanted it so next time …
Run Code Online (Sandbox Code Playgroud)

php arrays

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

ImportError:无法在Keras中导入名称TimeDistributedDense

我正在尝试为印地语到英语翻译运行一个示例代码。

当我运行提供的代码https://github.com/karimkhanp/Seq2Seq

Using TensorFlow backend.
Traceback (most recent call last):
  File "seq2seq.py", line 5, in <module>
    from model import seq2seq
  File "/home/ubuntu/Documents/karim/Data/bse/phase3/deep_learning/Seq2Seq/seq2seq/model.py", line 5, in <module>
    from keras.layers.core import Activation, RepeatVector, TimeDistributedDense, Dropout, Dense
ImportError: cannot import name TimeDistributedDense
Run Code Online (Sandbox Code Playgroud)

当我在Google上搜索时,我找到了此解决方案-https://github.com/fchollet/keras/tree/b587aeee1c1be1363363a56b945af3e7c2c303369ca

我尝试使用https://github.com/fchollet/keras/tree/b587aeee1c1be3633a56b945af3e7c2c303369ca上的代码Zip包

使用安装了keras,sudo python setup.py install但是当我运行提供的代码https://github.com/karimkhanp/Seq2Seq时,仍然遇到相同的错误。

如果有人找到任何解决方案,请提供帮助。

python deep-learning keras

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