PHP语法错误t_variable错误?

时间:2011-09-28 18:48:31

标签: php facebook

我试图发布到用户墙我有id和离线令牌存储在数据库中

$result22 = mysql_query("SELECT token FROM usersoffline", $link2);
$num_rows2 = mysql_num_rows($result22);
// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM usersoffline") 
or die(mysql_error());  
echo "<table border='1'>";
echo "<tr> <th>id</th> <th>Toekn</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
    // Print out the contents of each row into a table
    echo "<tr><td>"; 
    echo $row['uid'];
    echo "</td><td>"; 
    echo $row['token'];
    echo "</td></tr>"; 


$target = $row['uid'] ;
    $attachment =  array(
             'access_token' => $row['token'],
              'message' => 'Did a Test Post :',
                    'name' => "Offline posting using stored tokens",
                    'link' => "url",
                    'description' => "This post was made using a stored access token",
              'picture'=>"",
            );
    $ret_code=$facebook->api('/'.$target.'/feed', 'POST', $attachment);



} 
echo "</table>";

对某些人来说,它不是张贴???

2 个答案:

答案 0 :(得分:3)

$target = $row['uid']之后需要一个分号。

答案 1 :(得分:0)

  1. 确保您正确包含并初始化Facebook库:$facebook = new Facebook(...);
  2. 确保您的应用已授予publish_stream权限
  3. 将您的Facebook来电包裹在try/catch条款中 catch 错误 - reference
  4. 您不需要offline_access权限
  5. 根据#4,您无需在access_token var
  6. 中附加$attachment