2011-08-10 19 views
2

私はphp mysqlでfacebookアプリケーションを作成しましたが、アプリケーションの更新をユーザーの壁に渡したいと思います。そのようなボタンではなく、ユーザーの壁に共有したいアクティビティを渡します。多くのように:壁に投稿する方法

$facebook = new Facebook(array(
    'appId' => 'xxxxxxxxxxxxx', 
    'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 
)); 

// Get User ID 
$user = $facebook->getUser(); 

if ($user) { 
    try { 
    // Get the user profile data you have permission to view 
    $user_profile = $facebook->api('/me'); 
    $uid = $facebook->getUser(); 
    session_start(); 
    $_SESSION['userID'] = $uid; 

    //print_r($user_profile); 
    //echo "</pre>"; 
    } catch (FacebookApiException $e) { 
    $user = null; 
    } 
} else { 
    die('<script>top.location.href="'.$facebook->getLoginUrl().'";</script>'); 
} 

答えて

0

確実に動作します:あなたはそれが彼らに

$facebook = new Facebook(array(
    'appId' => 'xxxxxxxxxxxxxxxxxx', 
    'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 
)); 
$user = $facebook->getUser(); 
$user_profile = $facebook->api('/me'); 


if(array_key_exists('publish_stream', $permissions['data'][0])) { 
       // Permission is granted! 
       // Do the related task 
       //$post_id = $facebook->api('/me/feed', 'post', array('message'=>'Hello World!')); 
        $post_id = $facebook->api('/me/feed', 'post', $attachment); 

      } else { 
       // We don't have the permission 
       // Alert the user or ask for the permission! 
       echo "Click Below to Enter!"; 
       header("Location: " . $facebook->getLoginUrl(array("scope" => "publish_stream"))); 
      } 
を取得しようとする権限を持っていけない場合でも、
2

あなたが最初に付与されている必要があります

xxxはちょうどlogUrLunchのApp

を経由して、私はFacebookのに接続するために管理し、HVと次のようにFacebookのからユーザーIDを持って、昼食のためにピザを持っていましたpublish_streamextended permission

その後、あなたはtrueに設定auto_publishパラメータでのFacebookのJavascript SDKでstream.Publish方法を使用するか、また、これを実現するために使用することができ、グラフAPIドキュメントhereの「出版」のセクションをチェックアウトすることができます。コードの下

関連する問題