我目前正在使用Facebook Graph API开发一个Web应用程序.
我目前的目标是仅检索附有位置的帖子.
检索包含和不包含位置的帖子已经有效,我无法仅检索包含位置的帖子.
检索这两种类型的查询如下所示: '/me/feed?fields=id,name,message,picture,place,with_tags&limit=100&with=location'
应该仅检索具有位置的帖子的查询如下所示: /me/feed?fields=id,name,message,picture,place,with_tags&limit=100&with=location
&with=location
我遇到的问题是,使用参数我Uncaught (in promise) undefined
在代码的这一部分出错:
if (response.paging && response.paging.next) {
recursiveAPICall(response.paging.next);
} else {
resolve(postsArr);
}
} else {
// Error message comes from here
reject();
}
Run Code Online (Sandbox Code Playgroud)
日志显示以下内容:
DEBUG: -------------------------------
DEBUG: Ember : 2.4.5
DEBUG: Ember Data : 2.5.3
DEBUG: jQuery : 2.2.4
DEBUG: Ember Simple Auth : 1.1.0
DEBUG: -------------------------------
Object {error: Object}
error: Objectcode:
code: 1
1fbtrace_id: "H5cXMe7TJIn"
message: "An unknown error has occurred."
type: "OAuthException"
__proto__: …
Run Code Online (Sandbox Code Playgroud) 我有一个在Apache和Nginx作为反向代理的服务上运行的节点应用程序。
在同一服务器上,还运行一个节点REST API。
JavaScript代码如下所示:
api.js
// Express
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
// Express App
const app = express();
// Env
const PORT = process.env.PORT || 3000;
const NODE_ENV = process.env.NODE_ENV || 'development';
// Config
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cors());
// Routes
const users = require('./routes/users');
// Angular Http content type for POST etc defaults to text/plain at
app.use(bodyParser.text(), function ngHttpFix(req, res, next) {
try {
req.body = JSON.parse(req.body);
next();
} catch(e) …
Run Code Online (Sandbox Code Playgroud) 我目前正在开发 Angular 4 应用程序。
该应用程序使用 Auth0 进行身份验证,其语法与其他身份验证服务的语法非常相似。
身份验证的代码如下所示:
// auth.services.ts
@Injectable()
export class Auth {
public lock = new Auth0Lock(myConfig.clientID, myConfig.domain, myConfig.lock);
public userProfile: any;
public idToken: string;
public signUpIncomplete: boolean;
// Configure Auth0
private auth0 = new Auth0.WebAuth({
domain: myConfig.domain,
clientID: myConfig.clientID,
redirectUri: myConfig.redirectUri,
responseType: myConfig.responseType
});
// Create a stream of logged in status to communicate throughout app
private loggedIn: boolean;
private loggedIn$ = new BehaviorSubject<boolean>(this.loggedIn);
constructor(private router: Router, private http: Http) {
// Set userProfile attribute of …
Run Code Online (Sandbox Code Playgroud) 我目前正在开发一个使用Facebook Graph API的网络应用程序.
我想要实现的是获取用户的所有帖子.
但是,这并不容易,因为我必须对结果进行分页.
目前,我正在兑现承诺.
我试图实现的是用post对象填充数组.
因此,我使用的promises和递归不能按预期工作.
我的代码目前看起来如下:
// Here I retrieve the user with his or her posts,
// just the first 25 due to pagination
if (accessToken) {
return new Promise(resolve => {
FB.api('/me?fields=id,name,posts&access_token=' + accessToken, response => {
this.get('currentUser').set('content', response);
resolve()
})
})
}
// Returns all posts of a given user
function getAllPostsOfUser(posts, postsArr) {
// Process each post of the current pagination level
for (var post of posts.data) {
// Only store meaningful posts …
Run Code Online (Sandbox Code Playgroud) javascript recursion facebook-graph-api facebook-javascript-sdk es6-promise
我正在使用 Objective-C 和 Swift 开发 React Native 应用程序。
目前,我正在尝试使用使用 Promise 的更优雅的解决方案来替换当前使用 EventEmitter 的方法。
但是,我遇到了一些麻烦,因为我收到编译器/解释器的投诉,说我使用错误数量的参数调用我的方法:
ExceptionsManager.js:71 RecorderBridge.startRecording was called with 0 arguments but expects 1 arguments. If you haven't changed this method yourself, this usually means that your versions of the native code and JavaScript code are out of sync. Updating both should make this error go away.
然而,除了解析器和拒绝器之外,我实际上没有任何参数,编译器/解释器不应该抱怨它们。
我的代码如下所示:
记录器.js
...
startRecording = () => {
RecorderNative.startRecording();
};
...
Run Code Online (Sandbox Code Playgroud)
RecorderNativeModule.js
import { NativeModules } from 'react-native';
const { RecorderBridge } …
Run Code Online (Sandbox Code Playgroud) javascript ×3
angular ×1
api ×1
auth0 ×1
es6-promise ×1
ios ×1
nginx ×1
node.js ×1
objective-c ×1
react-native ×1
recursion ×1
rest ×1
swift ×1