[英]Send any kind of message to Facebook friend through graph API with privacy SELF
[英]how send message facebook friend through graph api using Accessstoken
任何人都可以幫助我使用圖形 API 向 Facebook 朋友發送消息。
我試過
$response = $facebook->call_api("/me/feed", "post", "to=john","message=You have a Test message");
它不起作用。 我手上有用戶的訪問令牌。只是我對發送過程感到困惑。
您無法使用 Facebook 應用程序發送消息。 你曾經能夠做到這一點,但(可預測的?)大量濫用導致此能力被撤銷。
如果您的用戶 Alice 為您提供了必要的 擴展權限,您有以下選擇:
您可以在彈出窗口中打開發送對話框。
$parameters = array(
'app_id' => $facebook->getAppId(),
'to' => $facebookUserId,
'link' => 'http://google.nl/',
'redirect_uri' => 'http://my.app.url/callback'
);
$url = 'http://www.facebook.com/dialog/send?'.http_build_query($parameters);
echo '<script type="text/javascript">window.open('.json_encode($url).', ...
有關詳細選項,請參閱: https : //developers.facebook.com/docs/reference/dialogs/send/
$attachment = array(
'access_token' => $access_token,
'message' => $msg,
'name' => $name,
'link' => $link,
'description' => $desc,
);
facebook->api('/'.$uesr_id.'/feed', 'POST', $attachment);
從技術上講,您可以使用隱私設置進行提要或交叉提要帖子,該設置僅允許提要所有者查看帖子,但不會真正向某人發送消息。
您可以發送到他們的 Facebook 電子郵件。 Facebook 電子郵件由個人資料昵稱+'@facebook.com' 組成。 該電子郵件將轉到他們的 Facebook 收件箱消息。 請注意,facebook 電子郵件不接受欺騙電子郵件。 您將需要白標域或使用 SendGrid。
您將需要集成 xmpp chat 來回復消息和編寫新消息。
You can use
HTTP POST with
PATH
https://graph.facebook.com/friend_facebook_id/feed
PARAMETER
MESSAGE = your message
ACCESS_TOKEN = your oauth2 access token
我看到這個帖子,發現不對。 使用 javascriot api,您可以像這樣發布到朋友的提要:在這個例子中,“friendID”是朋友的 FB 用戶 ID。 這個 api 調用需要“publish_stream”權限。
FB.api('/'+friendID+'/feed', 'post',
{
method: 'feed',
message: messageText,
name: 'write a title here',
caption: 'Put a caption here.',
description: 'Put your description here.',
link: 'http://stackoverflow.com/questions/2943297/how-send-message-facebook-friend-through-graph-api-using-accessstoken',
picture: 'link to the preview thumbnail',
},
function(response) {
if (!response || response.error) {
//alert('Error occured');
} else {
//alert('Post ID: ' + response.id);
}
});
所以這是通過 javasfcript SDK 實現的——PHP 方法必須類似。
而不是使用下面的代碼
[facebook dialog:@"feed"
andParams:params
andDelegate:self];
使用以下解決方案
[facebook requestWithGraphPath:@"me/feed"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
好像你想將消息直接發送到接收者的主要收件箱,沒有任何圖形API,你需要使用facebook xmpp chat api並發送消息,但是我已經制作了一個很容易的php類使用,只是一些函數調用和調用發送消息功能和消息將被發送,其開源,檢查出來: facebook消息api php描述說它是一個封閉源,但評論說它現在是一個開源,你可以從github克隆。 它現在是一個開源的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.