有没有办法用PHP做一个帖子

时间:2011-09-18 19:17:12

标签: php facebook post

我正在尝试对Facebook做一个简单的帖子,我有相同的样本来做一个邮政编码,我改变了一点。

我收到以下错误

解析错误:语法错误,意外';'在第13行的/home/consult/public_html/projects/facebook/index.php

该行是

'access_token'=>;urlencode($code),

代码:

<?php
//set POST variables
$url = 'https://graph.facebook.com/arjun/feed';
$code="testing";
$message="Test";
$fields = array(
    'access_token'=>;urlencode($code),
    'message'=>;urlencode($message),
                );

//url-ify the data for the POST
foreach($fields as $key=&gt;$value) { $fields_string .= $key.'='.$value.'&amp;'; }
rtrim($fields_string,'&amp;');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);

//execute post
// $result = curl_exec($ch);

//close connection
curl_close($ch);


?>

1 个答案:

答案 0 :(得分:2)

应该是

  'access_token'=>urlencode($code),

 'access_token'=>;urlencode($code),

另外,

'message'=>;urlencode($message),

应该是

'message'=>urlencode($message),

另外,

key=&gt;

应该是

key=>