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 -->