1

I have a strange error message after using the post to wall function. It did successfully post to the wall however i got a very weird strange error.

[30-Jan-2012 23:36:49] PHP Notice: Use of undefined constant message - assumed 'message' in C:\www\jetstar\starpick\rewards.php on line 33

[30-Jan-2012 23:36:49] PHP Notice: Use of undefined constant picture - assumed 'picture' in C:\www\jetstar\starpick\rewards.php on line 34

[30-Jan-2012 23:36:49] PHP Notice: Use of undefined constant link - assumed 'link' in C:\www\jetstar\starpick\rewards.php on line 35

[30-Jan-2012 23:36:49] PHP Notice: Use of undefined constant name - assumed 'name' in C:\www\jetstar\starpick\rewards.php on line 36

[30-Jan-2012 23:36:49] PHP Notice: Use of undefined constant caption - assumed 'caption' in C:\www\jetstar\starpick\rewards.php on line 37

This is the codes i use

$facebook->api("/me/feed", "post", array(
    message => "I have won a ".$prizename,
    picture => "http://i1172.photobucket.com/albums/r574/092810c/starpicklogo-1.png",
    link => "https://apps.facebook.com/starpick/",
    name => "StarPick",
    caption => "Stand to Win Attractive Prizes!!!"));
2
  • The answer is short: By understanding the error message. Which actually contains the solution if you read it carefully. Commented Jan 30, 2012 at 15:47
  • i think you should use $message,$picture etc or variable as u define. Commented Jul 31, 2015 at 6:05

2 Answers 2

9

You've forgotten quotes around your key names:

'message' => "I have won a ".$prizename,
^-------^--- missing

and the same for all the other parts of your array.

Keys in PHP MUST be quoted, otherwise they're assumed to be constants. PHP will politely treat undefined constants as unquoted strings, but will give you those warnings.

Sign up to request clarification or add additional context in comments.

Comments

0

The array keys should be put in quotes as well.

The good code is:

$facebook->api("/me/feed", "post", array(
"message" => "I have won a ".$prizename,
"picture" => "http://i1172.photobucket.com/albums/r574/092810c/starpicklogo-1.png",
"link" => "https://apps.facebook.com/starpick/",
"name" => "StarPick",
"caption" => "Stand to Win Attractive Prizes!!!"));

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.