I have the following code to send messages to selected friends by custom made
$friends = $facebook->api(array(
"method" => "fql.query",
"query" => "SELECT uid,name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())"
));
where $facebook is the one having the details of the application & key values.,
& I get my friends list into the $friends
I'll be having a textarea too to enter the message that has to be sent,
now I'll be passing the selected list of friends & message to a function as follows
function facebook_send_message(to,message) {
FB.ui({
app_id:'MY APP ID',
method: 'send',
name: 'Abcdef',
link: 'http://apps.facebook.com/',
to:to,
message:message
},function(response){alert(response);});
}
when this function was called, a facebook popup opens, but my form in which all these content is placed gets submitted,
I'm not able to send the message to the selected friends, do anyone can help me in this issue..
For sending message with custom text, you have added 'message' parameter to FB.ui, but this feature is Deprecated. You can't pre-fill the message anymore.
This was deprecated might be because of bad advertisements.
So don't use 'message' parameter for message.
Related
Hi guys I am having a problem with twilio currently setting an assignment to a worker and i need to pass the worker to the conference. My problem is that i cant use session to retrieve the id in the session and the id will be the conference name of the conference to be able to have a unique conference name for a worker.
This is my callback in twilio
This is my code to get the task. And the id will be passed on forward_queue_conference.
public function assignment()
{
id = $this->session->userdata('user_id');
$TaskAttributes = $_POST['TaskAttributes'];
$json = json_decode($TaskAttributes, true);
$this->Mytwilio->SetAssignment($json['from'], AFTERTALK, HTTP_BASE_URL."agent/call_controls/forward_queue_conference?data=".$id);
}
This is my code on forward_queue_conference to retrieve the pass data
public function forward_queue_conference()
{
roomName = $_GET['data'];
$this->Mytwilio->CallerToQueue($roomName);
}
MyTwilio is a library that i made for twilio functions.
function CallerToQueue($roomName)
{
$response = new Services_Twilio_Twiml;
$dial = $response->dial();
$dial->conference($roomName, array(
'startConferenceOnEnter' => 'true',
'endConferenceOnExit' => 'true',
'muted' => 'false',
'record' => 'record-from-start',
'waitUrl' => 'http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient',
));
print $response;
}
And this is my whole process my problem is that i cant get the session data to become the conference room.
Twilio developer evangelist here.
When Twilio makes a callback to a URL on your website, it does not share the same session as your logged in user. It is therefore impossible to get the current user ID from the session.
However, your workers have an ID in the Twilio system. And that ID is sent as part of the parameters for the webhook. So, I recommend using the WorkerSid as the conference room instead of your own ID. Or alternatively, you could map between your worker ID and the user ID in your system.
I'm trying to tag user(s) inside page post comments.
$fb_id = 'facebook_user_id_here';
$fb_name = 'facebook_user_name_and_surname_here';
$request = new FacebookRequest(
$this->session,
'POST',
$comment,
array(
'access_token' => $this->page_access_token, //it is access token of my page
'message => "Text here #[".$fb_id.":1:".$fb_name."]"
)
);
It shows only name and surname without Fb profile URL.
Like CBroe mentions in his comment, at this time this is not possible using the API.
For reference, this is called "mentioning" or "mention tagging", and personal profiles can only do this in messages on open graph actions (docs).
Pages can also mention other pages in comments. (docs)
I'm making a facebook app which will show a user's friends, then the user will choose a friend and the app will send that friend an apprequest with PHP.
With that apprequest I also will send the user's id, so that when the receiver plays the app, I will know that it will be thanks to that user.
To get a user's friends I'm using the following code
$friends_array = $facebook->api('/me/friends');
(I know this will only return a user's friends who have already accepted the app's permissions, so I'm using 2 test accounts which are friends)
To send the apprequest
If I use the following
$param = array(
'message' => 'Check out the latest update',
'data' => 'some_data_string',
"to" => $_POST["friend_id"],
"method" => "POST",
'access_token' => $facebook->getAccessToken(),
);
$tmp = $facebook->api("/me/apprequests", "POST", $param);
It is executed, but nothing is received.
If I use the following
$param = array(
'message' => 'Check out the latest update',
'data' => 'some_data_string',
'access_token' => $facebook->getAccessToken(),
);
$tmp = $facebook->api("/".$_POST["friend_id"]."/apprequests", "POST", $param);
I get the following error "Fatal error: Uncaught OAuthException: (#2) Failed to create any app request thrown ..."
The app is public and available to all users.
Do I need maybe to submit the app for any special permissions in order to post an apprequest?
Also if you have any other suggestion to have the desired results I'm referring to at the beginning, please reply.
I know we can publish something on a friend's wall with this:
$publishStream = $facebook->api("/$user/feed", 'post', array(
'message' => "Your Message",
'link' => 'http://example.com',
'picture' => '',
'name' => 'App Name',
'description'=> 'App description'
));
Just by replacing the $user variable with the user id of your friend.
What i wish is simply to choose among my friends, the user profiles i want to write on using check boxes.
this is something already possible if you want to share a fan page for instance. You choose the persons you send the request to.
Thanks in advance for your help
You can use Facebook's Multi-Friend-Selector (MFS).
https://developers.facebook.com/docs/guides/games/custom-muti-friend-selector/
An edited example taken from the Multi-Friend-Selector documentation
function renderMFS() {
// First get the list of friends for this user with the Graph API
FB.api('/me/friends', function(response) {
var container = document.getElementById('mfs');
var mfsForm = document.createElement('form');
mfsForm.id = 'mfsForm';
// Iterate through the array of friends object and create a checkbox for each one.
for(var i = 0; i < Math.min(response.data.length, 10); i++) {
var friendItem = document.createElement('div');
friendItem.id = 'friend_' + response.data[i].id;
friendItem.innerHTML = '<input type="checkbox" name="friends" value="'
+ response.data[i].id
+ '" />' + response.data[i].name;
mfsForm.appendChild(friendItem);
}
container.appendChild(mfsForm);
// Extract selected friends' Facebook ID from value property of checked checkboxes
// Do a for loop to send notification (refer to the link posted below) and publish post to each user's wall
});
}
And is it possible to send notifications before the messages are
written on the walls?
Yes it is possible when you have the Facebook ID. Refer to my answer in How to send Facebook message to friend using Facebook ID?
I'm using the following to post a message on my Facebook page:
$attachment = array(
'access_token' => $access_token,
'message' => 'This is a test Message 4:',
'name' => "This is a test Name 4",
'link' => "http://slashdot.org/",
'description' => "This is a test Description 4"
);
$ret_code=$facebook->api('/me/feed', 'POST', $attachment);
This works great.
How do I delete the same post using the facebook GRAPH api? I read the docs and it says to issue a POST like:
https://graph.facebook.com/COMMENT_ID?method=delete
To test I set this up in a simple form with submit button, POSTing the data to https://graph.facebook.com/COMMENT_ID?method=delete (substituting COMMENT_ID fro the 11111111111_111111111111 id returned from the original publish call. This returns "This API call requires a valid app_id".
What is the correct way to issue a DELETE command?
Since you are using the php-sdk you just issue this call:
$facebook->api("/COMMENT_ID","DELETE");
You can use the following code:
Http::post('https://graph.facebook.com/'.$fb_action_id, array('method'=>'delete', 'access_token'=>$your_app_access_token));
This post will return a boolean value, true if successed and false if failed.
Its been discussed here Facebook SDK and Graph API Comment Deleting Error
you need to pass the access token too. You can delete all the milestones of a page like follows:
$milestones = $facebook->api('/PAGE_ID/milestones');
foreach($milestones[data] as $milestone)
{
echo $milestone['id'];
$args = array(
'access_token' => $pages_access_token
);
$deleted = $facebook->api($milestone['id'],"delete",$args);
if($deleted)
{
echo " <font color=\"green\">OK</font><br>";
}
else
{
echo " <font color=\"red\">ERR</font><br>";
}
}