标签: fetch

如何使用$ _GET?

我有以下登录脚本,我在那里使用会话.

<?php
session_start();
if(isset($_SESSION['logged_in'])){
    $id = $_SESSION['id'];
    header("Location: start.php?id=$id");
    exit();
}

if(isset($_POST['submit'])){

    $x1 = $_POST['x1'];
    $x2 = $_POST['x2'];
...
$query = $db->query("SELECT * FROM table WHERE x1='".$x1."' AND x2='".$x2."'");
        if($query->num_rows === 1){

            $row = $query->fetch_object();
            $id = $row->id;

                        $_SESSION['logged_in'] = true;
            $_SESSION['id'] = $id;
            header("Location: start.php?id=$id");

                        3more queries
                        exit();
Run Code Online (Sandbox Code Playgroud)

start.php将是:

<?php
echo $_GET['id'];
?>
Run Code Online (Sandbox Code Playgroud)

我以为$ _GET ['id']会存储在服务器上,以便显示$ _GET.fetch_object正在运行.我知道,因为它将在浏览器的"id = $ id"中以正确的方式显示.所以有人会友好,可以帮助我.谢谢!

php session get fetch

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

如何在ios中获取Facebook用户信息

我正在尝试开发一个简单的应用程序,当用户连接到Facebook时,它会从Facebook检索数据.我试过这个代码.

NSArray *permissions = [[NSArray alloc] initWithObjects:@"user_birthday",@"user_hometown",@"user_location",@"email",@"basic_info", nil];

    [FBSession openActiveSessionWithReadPermissions:permissions
                                       allowLoginUI:YES
                                  completionHandler:^(FBSession *session,
                                                      FBSessionState status,
                                                      NSError *error) {
                                  }];

    [FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        NSLog(@"%@", [result objectForKey:@"gender"]);
        NSLog(@"%@", [result objectForKey:@"hometown"]);
        NSLog(@"%@", [result objectForKey:@"birthday"]);
        NSLog(@"%@", [result objectForKey:@"email"]);
    }];
Run Code Online (Sandbox Code Playgroud)

但是当我运行这段代码时,它会给出一个错误"FBSDKLog:对端点请求的错误'我':必须为这个端点的调用指定一个开放的FBSession."

在此先感谢,非常感谢您的帮助.

facebook fetch ios

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

无法查看数组的内容

我有一个包含"标题","颜色"等内容的数据库,我想在网页中显示这些信息.但是,由于某些未知的原因,什么都不会出现,甚至不会出现错误,这使得我完全迷失了.

我用这个把我需要的东西放到一个数组中:

<?php 
try{
$req = $db ->prepare("SELECT titre, couleur, categorie, img_url, prix, type FROM articles WHERE id = 9");
$article = $req ->fetch(PDO::FETCH_ASSOC);

}
catch(PDOException $e){
echo $e;
exit();
}
?>
Run Code Online (Sandbox Code Playgroud)

我与数据库的连接是成功的,但即使我使用了数据库,我甚至看不到我的数组的内容

<pre> <?php print_r($array) ?> </pre>
Run Code Online (Sandbox Code Playgroud)

技术.我的工作代码是基于我现有的代码,我不记得我做错了什么...提前谢谢你!

php arrays pdo fetch

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

使用PHAssetCollection.fetchAssetCollectionsWithType()从swift中的特定相册中获取照片

当我发布照片时:

let assetCollections: PHFetchResult = PHAssetCollection.fetchAssetCollectionsWithType(.SmartAlbum, subtype: .Any, options: nil) 
Run Code Online (Sandbox Code Playgroud)

我得到了几张专辑的结果,所以我可以遍历数组并将它们的标题放在tableView中.

但是:当我使用谓词来过滤并获得例如专辑"Camera Roll"时,结果总是一个空数组:(而且我知道100%确定相机卷存在,因为它使用nil选项获取它)

let fetchOptions = PHFetchOptions()
fetchOptions.predicate = NSPredicate(format: "title = %@", "Camera Roll")
let assetCollections: PHFetchResult = PHAssetCollection.fetchAssetCollectionsWithType(.SmartAlbum, subtype: .Any, options: fetchOptions)
let album: PHAssetCollection = assetCollections.firstObject as! PHAssetCollection
Run Code Online (Sandbox Code Playgroud)

我已经在线阅读了4种或5种不同的方法,他们都有这个谓词,无论是"title =%@",还是"localizedTitle =%@"或"localizedIdentifier =%@"......我都不知道它.似乎为人们工作,而不是为我工作.编译器在最后一行崩溃,试图"展开一个nil可选值"('cos获取结果为空).为什么一旦包含获取选项,搜索返回nil ???

predicate filter photos fetch swift

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

为什么mysql_fetch的和值增加了一倍?

我有一个2数据库.

1是game_jnship_user,2是game_jnship_equip和以下数据:

这是 game_jnship_user

+-----+-----------------+
| ID  | uid             |
+-----+-----------------+
| 1   | 50              |
+-----------------------+
Run Code Online (Sandbox Code Playgroud)

这是 game_jnship_equip

+-----+------------+---------------+--------------+
| ID  | uid        | ebonus        | etype        |
+-----+------------+---------------+--------------+
| 1   | 50         | 100           | 1            |
| 2   | 50         | 10            | 1            |
| 3   | 50         | 120           | 2            |
+-------------------------------------------------+
Run Code Online (Sandbox Code Playgroud)

我查询如下:

$_G['uid'] = '50';
$ushuxing = DB::query("SELECT sum(t2.ebonus) AS equipatk, sum(t3.ebonus) AS equipdef FROM ".DB::table('game_jnship_user')." t1 LEFT JOIN …
Run Code Online (Sandbox Code Playgroud)

mysql fetch

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

理解js中的fetch

我检查了一些资源,但没有真正得到fetch方法.

2 then-s有什么意义?第一个和第二个then好处是什么?为什么是return第一个?

fetch('http://some-site.com/cors-enabled/some.json')  
  .then(function(response) {  
    return response.text();  
  })  
  .then(function(text) {  
    console.log('Request successful', text);  
  })  
  .catch(function(error) {  
    log('Request failed', error)  
  });
Run Code Online (Sandbox Code Playgroud)

javascript fetch promise service-worker

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

从响应本地获取调用获取文本

我无法解析提取调用中的数据

下面是方法

onLoginPress=()=>{
      console.log("username="+this.state.username);
      console.log("password="+this.state.password);
      this.sendLoginRequest(this.state.username,this.state.password)
      .then((response) => {
          console.log("RESPONSEEEEEEEEEEEEEEEE");
          console.log(response.text())
          console.log( Promise.resolve(response));
          response.json();
      })
      .then((responseJson) => {

        console.log(responseJson);
      })
      .catch((error) => {
        console.error(error);
      });


    };
Run Code Online (Sandbox Code Playgroud)

我得到的回应是一个承诺,我无法摆脱它的代币。

以下是response.text()的日志

{_45:0,_81:1,_65:““ 3h8112qe2qobox3675ghmq9dtcbjvddc”',_ 54:空}

对于console.log(Promise.resolve(response))的输出是

{ 
_45: 0,
_81: 1,
_65: { type: 'default',
  status: 200,
  ok: true,
  statusText: undefined,
headers: { map: { connection: [ 'Keep-Alive' ],
'content-length': [ '34' ],
'content-type': [ 'application/json; charset=utf-8' ],
'set-cookie': [ 'persistent_shopping_cart=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/' ],
'cache-control': [ 'no-store, no-cache, must-revalidate' ], …
Run Code Online (Sandbox Code Playgroud)

response fetch react-native

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

在渲染器外部使用StackNavigation访问传递的数据

我能fetch一个ListView并显示详细信息页面onPress的任何列表项的。我可以在中显示被点击项目的详细信息,DetailsPage但只能在中显示render()。如何访问渲染之外的任何值?我想将该值用于fetch其他API的信息

主页:

import React, { Component } from 'react';
import { 
 AppRegistry, StyleSheet, ListView, 
 Text, TouchableHighlight, View
} from 'react-native';

import { StackNavigator } from 'react-navigation';
import DetailsPage from './src/DetailsPage';    

class HomeScreen extends React.Component {
  static navigationOptions = {
    title: 'MyApp!',
  };

   constructor() {
    super();
    const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
    this.state = {
      userDataSource: ds,
    };
  }

  componentDidMount(){
      this.fetchUsers();
  }

    fetchUsers(){

        fetch('https://jsonplaceholder.typicode.com/users') …
Run Code Online (Sandbox Code Playgroud)

fetch reactjs react-native react-navigation

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

什么是处理提取响应的正确方法

我有以下代码用于处理Magento 2 REST API。

return new Promise((resolve, reject) => {
      fetch(uri, { method, headers, body: JSON.stringify(data) })
        .then(response => {
          return response.json();
        })
        .then(responseData => {
          resolve(responseData);
        })
        .catch(error => {
          reject(error);
        });
    });
Run Code Online (Sandbox Code Playgroud)

我想添加响应状态检查,所以我已经开始像这样

return new Promise((resolve, reject) => {
      fetch(uri, { method, headers, body: JSON.stringify(data) })
        .then(response => {
          return {
            data: response.json(),
            ok: response.ok,
            status: response.statusText
          };
        })
        .then(responseResult => {
          if (responseResult.ok) {
            resolve(responseResult.data);
          } else {
            const error = responseResult.status || responseResult.data.message;
            reject(error);
          }
        }) …
Run Code Online (Sandbox Code Playgroud)

javascript fetch promise

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

使用Axios时应该使用Promises吗?

Axios被描述为基于Promise的,因此在使用Axios查询数据时是否需要返回新的Promise?

app.get('/api/nearbyRecommendations', async (req, res) => {

    if(!req.query) return res.send({ error: 'Please enable location to get recommendations.' })

    try {
        const { longitude, latitude } = req.query
        const locationName = await location.getLocationName(longitude, latitude)
        res.send(locationName)
    } catch (error) {
        res.send(error)
    }
})   
Run Code Online (Sandbox Code Playgroud)

我正在向MapBox API发出GET请求,但是即使为.xn()块中添加了一个新的Error,尽管为Axios请求设置了catch块,我也似乎从未收到任何错误。

const getLocationName = async (latitude, longitude) => {
    return new Promise((resolve, reject) => {
        axios.get(`https://api.mapbox.com/geocoding/v5/mapbox.places/${longitude},${latitude}.json?access_token=${darkSkyAPIKey}`, {json: true})
        .then(response => {
            if(!response.data) return reject({ error: 'No location found.' })

            resolve(response.data)
        }).catch(error => {
            reject(error)
        })
    })
}
Run Code Online (Sandbox Code Playgroud)

如果可能的话,请提供帮助并指出可能进行更改以遵循最佳实践的任何内容。

javascript fetch promise async-await axios

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