facebook-actionscript-api delete request issue - facebook

I'm trying to delete a user-to-user request using facebook-actionscript-api. So far no success..I've tried the following codes:
//try #1
var data:Object = new Object();
data.method = 'delete';
var userid:String = "idOfTheRequestSender"; //id of the request sender
var fullrequestID:String = requestId + '_'+ userid;//requestId - id of the sent request
Facebook.api(fullrequestID, onRequestDeleteCallBack, data, "POST");
//try #2
var userid:String = "idOfTheRequestSender"; //id of the request sender
var fullrequestID:String = requestId + '_'+ userid; //requestId - id of the sent request
Facebook.deleteObject(fullrequestID, onRequestDeleteCallBack);
I am replacing the userid with what it should be in my app.
Neither works as the callback function parameter is always null and the request is not deleted. Any help would be appreciated.Thanks.
The problem is just deleting the requests, i am able to send them.
EDIT:
The problem was that i was trying to delete the request from the Facebook account that sent the request, not from the account that received the request. Now it works. Thanks.

Did you try :
Facebook.api(fullrequestID, onRequestDeleteCallBack, {}, "DELETE");
Also are you getting any error messages?

Related

How to send message later in bot framework?

I want my bot to be able to send some replies later. Like in alarm clock, when user says, ping me at 5 AM then I want to send message to the user at 5 AM. How can I send message without receiving one?
You'll need to receive at least one message so that you know the recipient's address. You'll need to save the addressing info from the incoming message. I think the easiest way is to save the whole message.
Nodejs:
var reply = session.message; // address: reply.address
// ...
reply.text = 'Wake up!';
bot.send(reply);
C#:
var reply = activity.CreateReply(""); // reply.Recipient, reply.Conversation, etc.
// ...
reply.Text = "Wake up!";
ConnectorClient connector = new ConnectorClient(new Uri(reply.ServiceUrl));
await connector.Conversations.ReplyToActivityAsync(reply);
Without reply to an activity request, you can send a message to him like the following. I should mention that you must have the user's Id, and it means at least the user should have sent a message to the bot, to store his id.
string userId ="123456789"; // For Example
string serviceUrl = "https://telegram.botframework.com"; // For Example
var connector = new ConnectorClient(new Uri(serviceUrl));
IMessageActivity newMessage = Activity.CreateMessageActivity();
newMessage.Type = ActivityTypes.Message;
newMessage.From = new ChannelAccount("<BotId>", "<BotName>");
newMessage.Conversation = new ConversationAccount(false, userId);
newMessage.Recipient = new ChannelAccount(userId);
newMessage.Text = "<MessageText>";
await connector.Conversations.SendToConversationAsync((Activity)newMessage);
The above code comes from here.

Get email address with Xamarin.Auth and Facebook authentication

I have the following code to try connect the authenticator
var auth = new OAuth2Authenticator (
appId,
"email",
new Uri ("https://m.facebook.com/dialog/oauth/"),
new Uri ("http://www.facebook.com/connect/login_success.html"));
and when the dialog shows, I can see that it is requesting permission to see my email. But how do I get that email from the service?
I make the following call to get the Facebook ID
var request = new OAuth2Request ("GET", new Uri ("https://graph.facebook.com/me"), null, args.Account);
request.GetResponseAsync ().ContinueWith (t => {
var obj = JsonValue.Parse (t.Result.GetResponseText ());
var id = obj ["id"];
});
But there is no email in the reponse that I get back. How can I get the email address of the user?
The lastest API version (2.4 at time of writing) uses Declarative Fields, so you need to explicitly request the email field like this:
https://graph.facebook.com/me?fields=email

How can I cancel my scheduled mail in sendgrid?

I have scheduling mail using 'send_at' with future time. Now I want to cancel that scheduled mail. How can achieve this problem. Please provide the solutions for it.
Thanks in advance.
Turns out that you can cancel scheduled email in sendgrid.
Here are the docs on how to do so
Mainly.. "Scheduled sends can be cancelled, if you include a batch ID with your send. "
The docs show you how to add the batch ID to your outbound messages so you can cancel them in the future.
As per the documentation, you cannot cancel scheduled messages at this time: https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html
This can be doable , by creating and assigning batchid in request
Create batch ID,
var batchId="";
var client = new SendGridClient(apikey);
var response = await client.RequestAsync(method:
SendGridClient.Method.POST, urlPath: "mail/batch");
if (response.StatusCode == HttpStatusCode.Created)
{
JObject joResponse = JObject.Parse(response.Body.ReadAsStringAsync().Result);
batchId = (((Newtonsoft.Json.Linq.JValue)joResponse["batch_id"]).Value).ToString();
}
return batchId;
Added batchId in Message body
var msg = new SendGridMessage()
{
From = new EmailAddress("youremail#abc.com", ""),
Subject = subject,
PlainTextContent = message,
HtmlContent = message,
BatchId=batchId
};
var offset = new DateTimeOffset(timeToSend.Value);
long sendAtUnixTime = offset.ToUnixTimeSeconds();
msg.SendAt = sendAtUnixTime;
msg.AddTo(new EmailAddress("recipientmail#abc.com"));
var response = await client.SendEmailAsync(msg);
3)Cancel a scheduled batch
var batchId="yur batch id"
var client = new SendGridClient(apiKey);
string data = "{\"batch_id\":\"" + batchId +"\",\"status\": \"cancel\"}";
var response = await client.RequestAsync(method: SendGridClient.Method.POST,
urlPath: "user/scheduled_sends", requestBody: data);
Note:
Make sure your api key has full access using sender grid option.
Setting --> apiKeys ---> edit Api key--> select "full access" and update
When a batch is canceled, all messages associated with that batch will stay in
your sending queue. When their send at value is reached, they will be discarded.
for more detail please refer enter link description here

Paypal Invoicing API, SendInvoiceRequest returns invoice null error

I'm using the C# SDK for our implementation (Classic API).
I can create an invoice fine, but whenever I try to send an invoice the response comes back with an error "Invalid request parameter: invoice cannot be null".
var result = new SendInvoiceResult();
var service = new PayPal.Invoice.InvoiceService(PayPalConfig());
var envelopeRequest = new RequestEnvelope
{
errorLanguage = "en_US", detailLevel = DetailLevelCode.RETURNALL
};
var request = new SendInvoiceRequest ( envelopeRequest, invoiceId );
var response = service.SendInvoice(request);
If I use the CreateAndSendInvoice method instead then a similar thing happens - the invoice gets created (I can view the URLs and the invoice shows as in draft) but it never sends.
Does anyone know what I'm doing wrong here?

Facebook get number of sent requests and accepted request

i need to make a page that will have a request dialog for a facebook page or a facebook app.
I need to get the number of friends the user sent the request to and at the end of the day the number of request that got accpeted from the specific user.
The scenario is for giving awards , the user that sent the most request to freinds gets an award and the user that had the most requests accepted also gets an award.
I dont know if the seccond is possible , but i think it should be , couse games on FB give u points for sent request and also u get new missions when friends accept your request , so there mut be a way.
--
I will record the number of invites sent.
Return Data
request_ids
A comma-separated list of the request_ids that were created. To learn who the requests were sent to, you should loop through the information for each request object identified by a request id.
FB.ui({
method: 'apprequests',
title:'Suggest '+fbAppName+' to your friends',
message: 'I thought you would dig this app!',
data: 'gameID=96'
}, onInviteFriend);
//jquery required for ajax function
onInviteFriend = function(response) {
if (response && response.request_ids) {
var idsLength = response.request_ids.length;
var idList = "";
var data = {};
var ajaxSettings = {};
for (var i = 0; i < idsLength; i++){
idList += response.request_ids[i];
if (i < idsLength-1){
idList += ",";
}
}
if (idsLength > 0){
data.idList = idList;
ajaxSettings = {
type: "GET",
url: sketchnpass.root+"/ajax/log-invite-sent/",
data: data,
success: sketchnpass.onSaveInvites
};
$.ajax(ajaxSettings);
}
//was published
} else {
//was not published
}
}
i think using the code above i can get the number of sent requests.
But when some1 accepts the request how will i know that happened , does the accepted request send the user to my app along with some data?
The Facebook requests dialog documentation basically walks you through how to do this.
When requests are sent, request_ids is returned as return data so you would want to log this information in your system to track who sent how many requests.
To track accepted invitations, the documentation says that this url is called: http://apps.facebook.com/[app_name]/?request_ids=012345678910 so you would just need to parse the request id and look that request id up in your system and mark it as accepted.