drsrq26482 2011-12-19 11:44
浏览 53
已采纳

在PHP数组中使用$ _GET()

I have a PHP array:

$params = array(
  "name" => "$name",
  "description" => "not applicable", 
  "location" => "Orem Utah",
  "start_time" => "07/25/2013",
  "end_time" => "07/26/2013",
  "privacy_type" => "OPEN"
); 

The only way I can get the $name array to work, is if I use strings such as "name"

$name = $_GET['name']; Does not work.

How do I properly put $_GET into this array?

Here's my entire code...

<?php

  session_start(); 
  $app_id = "xxxxxxx";
  $app_secret = "xxxxxxxx";
  $my_url = "http://www.xxxxxxxx.xxxx/xxxxxxxxxevent.php?name=".urlencode($_SESSION['name']).""; 

  $code = $_REQUEST["code"];

  if (empty($code)) {
    $auth_url = "http://www.facebook.com/dialog/oauth?client_id="
    . $app_id . "&redirect_uri=" . urlencode($my_url)
    . "&scope=create_event";
    echo("<script>top.location.href='" . $auth_url . "'</script>");
  }

  $token_url = "https://graph.facebook.com/oauth/access_token?client_id="
  . $app_id . "&redirect_uri=" . urlencode($my_url)
  . "&client_secret=" . $app_secret
  . "&code=" . $code;
  $access_token = file_get_contents($token_url);

  $test = "$_GET[name]";
  $url = "https://graph.facebook.com/me/events?" . $access_token;
  $params = array(
    "name" => "$name",
    "description" => "not applicable", 
    "location" => "Orem Utah",
    "start_time" => "07/25/2013",
    "end_time" => "07/26/2013",
    "privacy_type" => "OPEN"
  ); 

  // Check if we have an image

  // Start the Graph API call
  $ch = curl_init();

  curl_setopt($ch, CURLOPT_URL,$url);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $params);

  $result = curl_exec($ch);
  $decoded = json_decode($result, 1);
  curl_close($ch);

  if (is_array($decoded) && isset($decoded['id'])) {
    $msg = "success";
  }
  $event_url = "https://graph.facebook.com/me/".$_SESSION['fid']."?" . $access_token;
  if (isset($msg)) {
    $_SESSION['fid'] = $decoded['id']; header("location:xxxxxx2.php");
  }

?>
<!-- irrelevant HTML BELOW HERE -->
  • 写回答

4条回答 默认 最新

  • doucigua0278 2011-12-19 11:48
    关注
    $params = array("name" => $name, "description" => "not applicable", "location" => "Orem Utah", "start_time" => "07/25/2013", "end_time" => "07/26/2013", "privacy_type" => "OPEN");
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看