小编Ron*_*Ron的帖子

如何在带有Express的NodeJS中使用带有passport-facebook的Facebook Graph API

在提出这个问题之前,我已经提到了以下但没有帮助我

  1. Passport.js和Facebook Graph API
  2. 使用passport-facebook从Facebook检索照片
  3. https://www.hitchhq.com/facebook-graph-api/docs/facebook-authentication
  4. http://tech.bigstylist.com/index.php/2017/08/12/search-facebook-graph-api-nodejs/
  5. 如何在使用Passport.js facebook策略进行身份验证后使用Facebook Graph API? 在此输入链接描述

有些帖子说要使用passport-facebook-token但是我不想使用,因为我想扩展我的应用程序的现有功能只有passport-facebook

问题陈述

目前,我使用passport-facebook进行身份验证,效果很好.现在我想扩展功能,使用Facebook Graph API来获取登录我的应用程序的用户的照片

因此,使用Facebook Graph API在Node JS中使用请求模块获取我必须在下面调用的用户照片,正文部分将返回给我预期的结果

var request = require("request");

var options = {
    method: 'GET',
    url: 'https://graph.facebook.com/me/photos/',
    qs: {
        access_token: 'EBBCEdEose0cBADwb5mOEGISFzPwrsUCrXwRWhO87aXB9KsVJlgSLc19IdX9D9AKU7OD5SdFOqPXW3eLm8J3HltZC14VexdMsEDW35LDWASdVDNGp5brFERBETsIvxXJIFXo7QSum5apHXeRyQk7c2PQljmf5WHObZAwXVzYjqPd4lziKTUK48Wfrw5HPwZD'
    },
    headers: {
        'content-type': 'application/json'
    }
};

request(options, function (error, response, body) {
    if (error) throw new Error(error);

    console.log(body);
});
Run Code Online (Sandbox Code Playgroud)

但是现在我想创建我的自定义快速GET API,当我调用我应该得到上面的身体响应,

喜欢 GET : /graph/photos

app.get('/graph/photos', function (req, res) {
    res.send(body)//Here I wanted to get the same response as of …
Run Code Online (Sandbox Code Playgroud)

facebook node.js facebook-graph-api passport-facebook passport.js

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

Angular Typescript - exclude在tsconfig.json中不起作用

目前我正面临node_modules中的一个模块的问题,而r编译Angular 4项目并得到如下错误因此我决定在tsconfig.json中排除这个项目,但我仍然得到错误,有人可以帮我吗这里

ERROR in D:/workspace/demo/node_modules/@types/d3-collection/index.d.ts (148,23): ',' expected.

ERROR in D:/workspace/demo/node_modules/@types/d3-collection/index.d.ts (483,40): ',' expected.

ERROR in D:/workspace/demo/node_modules/@types/d3-collection/index.d.ts (148,25): Type parameter name cannot be 'any'
Run Code Online (Sandbox Code Playgroud)

因此我决定排除node_modules以避免这些错误,但在运行时我仍面临同样的错误 npm start

tsconfig.json

{
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es6",
      "dom"
    ],
    "mapRoot": "./",
    "module": "es6",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc",
    "sourceMap": true,
    "target": "es5",
    "typeRoots": [
      "../node_modules/@types"
    ]
  },
  "exclude": [
    "**/node_modules/*"
  ]
}
Run Code Online (Sandbox Code Playgroud)

npm typescript tsconfig angular

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

使用Strict Equal在Javascript中无法进行比较

我有以下基本Javascript来反转我使用时工作的数字

while (!no == 0)

但是当我使用时不起作用

while (!no === 0)

我已经尝试在控制台中只parseInt(0)返回,number而我no已经是number这样

为什么===不工作,有人可以帮助并更好地解释我吗?

function findRepeated(number) {
  var a, no, b, temp = 0;

  no = parseInt(number);


  while (!no == 0) {
    a = no % 10;
    no = parseInt(no / 10);
    temp = temp * 10 + a;
  }
  return temp;
}

console.log(findRepeated(123));
Run Code Online (Sandbox Code Playgroud)

javascript

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

Angular 8 - URL 使用 routerLink 加载,但在 LOCALHOST 的浏览器中直接访问时不显示

我开发了 Angular 8 应用程序,我正在使用 routerLink 来导航组件,这些组件工作正常,没有任何问题,但是当我直接在浏览器中输入相同的 URL 时,它没有显示任何内容,并且在控制台中,我看到了错误如下

在此处输入图片说明

例如,我打开主页http://localhost:4200/home并在此处添加了 routerLink 以转到http://localhost:4200/about并且我将能够成功查看但如果我输入 URL http ://localhost:4200/about直接在 ULR 里什么都没有显示

我已经处理了 app-routing.model.ts

const routes: Routes =
    [
        { path: 'home', component: HomeComponent },
        { path: 'about', component: AboutComponent },
        { path: '**', redirectTo: '/home', pathMatch: 'full' }
    ];
    @NgModule({
    imports: [RouterModule.forRoot(routes)],
    exports: [RouterModule]
})
Run Code Online (Sandbox Code Playgroud)

我有 header.component.ts 来处理导航栏,所以我 <router-outlet></router-outlet>在 header.component.html 中添加了<app-header></app-header>,然后在app.component.ts 中包含了 header.component.ts 的选择器,然后在最后的index.js 中包含了 header.component.ts 的选择器 。 html 我已经包含了 app.component.ts 的选择器,即<app-root></app-root>

你能告诉我是否有问题。

在问这个问题之前,我已经经历了下面的一切,没有任何帮助

  1. RouterLink 不起作用 …

routelink angular-routing angular angular-routerlink

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

无法执行目标org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:声纳

任何人都可以帮助我获得以下错误的解决方案.

以下是要配置的组件的版本

  1. SonarQube 5.1.2
  2. Soanr-Runner 2.4
  3. Java 1.7 [ 我必须使用1.7,因为我的代码只支持1.7 ]
  4. mavn 3.3.9
  5. 声纳的Cobertura-插件-1.6.3
  6. 声纳的FindBugs-插件-3.3
  7. cobertura 2.6

执行命令

mvn -fn -e org.sonarsource.scanner.maven:sonar-maven-plugin:RELEASE:sonar -Dsonar.jdbc.url="jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance" -Dsonar.host.url=http://localhost:9000 -DskipTests
Run Code Online (Sandbox Code Playgroud)

在控制台窗口中我收到错误

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:
3.2:sonar (default-cli) on project NWT_Core: Execution default-cli of goal org.s
onarsource.scanner.maven:sonar-maven-plugin:3.2:sonar failed: Unable to load the
 mojo 'sonar' in the plugin 'org.sonarsource.scanner.maven:sonar-maven-plugin:3.
2' due to an API incompatibility: org.codehaus.plexus.component.repository.excep
tion.ComponentLookupException: org/sonarsource/scanner/maven/SonarQubeMojo : Unsupported major.minor version 52.0 
Run Code Online (Sandbox Code Playgroud)

sonar-runner sonarqube maven-cobertura-plugin

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

在RxJs中满足条件后如何立即退订

我是RxJ观察站的新手,一旦满足条件,我将难以取消订阅循环,请您帮我一下

在下面的函数中,如果代码到达if块,我想退订Observables

在问这个问题之前,我先经历了以下问题,但没有一个对我有太大帮助

  1. Rxjs可观察到,直到满足某些条件
  2. AngularJs-RXJS可观察的退订

Javascript功能

this.router.events.subscribe((url: any) => {
    url = this.router.url;
    if ((url === "/profile" || url === "/summary") && this.filterConfigFlag === false) {

        /*
        Perform operations
        */

    } else {
        console.log(typeof (url), url);

    }
});
Run Code Online (Sandbox Code Playgroud)

javascript observable rxjs angular

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

如何在一个html标记中使用ng if else来获取条件

任何人都可以帮我解决下面的问题,目前我正在使用下面的代码来显示我使用这两个<td>标签导出条件值的值,有什么办法可以在一个<td>标签中做其他的吗?

<td class="features" ng-if="OrderStatus.length>0">
<span ng-repeat="indi in ServiceDisconnects.Service">{{indi.serviceID}}<br></span>
</td>

<td class="features" ng-if="!OrderStatus.length>0">
<span ng-repeat="indi in ServiceDisconnects.Service">{{indi.productID}}<br></span>
</td>
Run Code Online (Sandbox Code Playgroud)

angularjs angular-ng-if

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

Angular JS orderBy不与Dates合作

orderBy 功能不适用于我尝试使用的日期 ng-repeat

在这里,我想对基于的托管进行排序 executedOn

我想排序元素,最新日期应该反映在顶部.

有人能帮我吗

var app = angular.module('myApp', []);

app.controller('MainCtrl', function($scope) {

    $scope.details = [
  {
    "id": 255463,
    "orderId": 226433,
    "status": 1,
    "executedOn": "25/Sep/17",
    "executedBy": "Person A",
    "executedByDisplay": "Person A",
    "cycleId": 4042,
    "cycleName": "Cycle A",
    "versionId": 21289,
    "versionName": "Version A",
    "issueKey": "A"
  },
  {
    "id": 255433,
    "orderId": 226403,
    "status": 1,
    "executedOn": "1/Mar/17",
    "executedBy": "Person B",
    "executedByDisplay": "Person B",
    "cycleId": 4041,
    "cycleName": "Cycle B",
    "versionId": 21289,
    "versionName": "Version A",
    "issueKey": "B"
  },
  {
    "id": 255432,
    "orderId": 226402,
    "status": …
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-ng-repeat angularjs-orderby

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

无法在Typescript Angular 5中读取未定义的属性值

我在使用Angular 5服务时面临以下问题,请您帮我解决下面的代码有什么问题

我已经解决了以下问题,但没有帮助我

  1. 问题1
  2. 问题2
  3. 问题3

我只想初始化类中的值并在方法中使用它

虽然我已经在类中定义的URL值我得到误差Cannot read property 'url' of undefined为线console.log(this.url);

@Injectable()
export class OwnService {

    public accessTokenvalue = '';
    public url = 'https://www.someurl.com/id=';
    constructor(private hp: HelpService) {
    }

    public gethpPhotos() {
        this.hp.login()
            .then(function (response: LoginResponse) {
                console.log(response);
                console.log(this.url);

            })
            .catch((error: any) => console.error(error));
    }
}
Run Code Online (Sandbox Code Playgroud)

typescript angular-services angular angular5

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

如何使用 File Saver 在 Angular 中下载 Excel 文件

我在 PHP 中创建了帖子表单,单击按钮就会下载一个 excel 文件,并且我还有一些表单数据也发布到 URL 和文件,用于使用纯 HTML 成功下载并提交表单

在 PHP 中,这是当表单发布到文件时触发的函数

public function downloadExcel($fileName = '', $addTimeStamp = true) {
    $fileName = (!$fileName) ? 'excel_download' : preg_replace('/\s+/', '_', $fileName);
    if ($addTimeStamp) {
        $fileName .= date('_d_m_Y_H_i_s');
    }
    $fileName .= '.xlsx';
    $this->setActiveSheetIndex(0);
    header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
    header('Content-Disposition: attachment;filename="' . $fileName . '"');
    header('Cache-Control: max-age=0');
    header('Cache-Control: max-age=1');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Cache-Control: cache, must-revalidate');
    header('Pragma: public');
    $objWriter = PHPExcel_IOFactory::createWriter($this, 'Excel2007'); …
Run Code Online (Sandbox Code Playgroud)

php download phpexcel angular

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

如何在 Angular 的 innerHTML 中使用 ng-template

有人可以帮助我,如何在innerHTML 标签中使用ng-template,

Stackblitz 演示:https ://stackblitz.com/edit/angular-xgnnj4

我想做的是,

在组件 HTML 中

<div [innerHTML]="htmlString"><div>
Run Code Online (Sandbox Code Playgroud)

在组件 TS

@ViewChild('dynamicComponent', { static: false, read: ViewContainerRef }) myRef: ViewContainerRef;

htmlString = `<ng-template #dynamicComponent></ng-template>`;

  ngAfterViewInit(): void {
    const factory = this.componentFactoryResolver.resolveComponentFactory(CommentComponent);
    const ref = this.myRef.createComponent(factory);
    ref.changeDetectorRef.detectChanges();
  }
Run Code Online (Sandbox Code Playgroud)

我真的需要以这种方式实现,因为我想从 API 获取 HTML 内容并使用该值动态显示 HTML 内容

当我收到错误时无法读取未定义的属性“createComponent”,但如果我将其放在innerHTML 之外,它可以完美运行

我已经浏览了https://angular.io/guide/dynamic-component-loader但它对我的场景没有帮助

innerhtml angular2-template ng-template angular angular-dynamic-components

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

仅对具有绝对值的数组排序并显示实际值

打印绝对排序数组。请参阅示例输出以进行澄清。

输入:

9 -2 10 3 -5 34 -22 7
Run Code Online (Sandbox Code Playgroud)

我想要输出:

-2 3 -5 7 9 10 -22 34
Run Code Online (Sandbox Code Playgroud)

我尝试过 Arrays.sort(a[]);

请帮助我:

谢谢

java

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