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 Matlab问题解答有两个问题
  • ¥50 Oracle Kubernetes服务器集群主节点无法访问,工作节点可以访问
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。
  • ¥15 stm32的can接口不能收发数据
  • ¥15 目标检测算法移植到arm开发板
  • ¥15 利用JD51设计温度报警系统
  • ¥15 快手联盟怎么快速的跑出建立模型