-3

I have asked an question, here: Send JSON by cURL always returns "No access".

A kind-man has answered me by this code:

<?php

//API URL
$url = 'http://www.example.com/test.php';
$data = "?code=Sh9QA&token=0982ff3066a3c60dbd3ecf9bcafc801b"

//Initiate cURL.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//Execute the request
$result = curl_exec($ch);

?>

But, I can't run it. It returns an error:

Parse error: syntax error, unexpected T_VARIABLE in D:\XAMPP\htdocs\test.php on line 8

I am using PHP 5.3 for my own working.

Is there any to fix it?

Community
  • 1
  • 1

2 Answers2

1

After $data = "?code=Sh9QA&token=0982ff3066a3c60dbd3ecf9bcafc801b" you missed a ;

Sigee
  • 362
  • 2
  • 11
0

You're missing a semicolon on line 5;

<?php

//API URL
$url = 'http://www.example.com/test.php';
$data = "?code=Sh9QA&token=0982ff3066a3c60dbd3ecf9bcafc801b"; //here

//Initiate cURL.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

//Execute the request
$result = curl_exec($ch);

?>
paullb
  • 4,293
  • 6
  • 37
  • 65