It used to be that the response from a request gave us an array of request ids (as described here http://developers.facebook.com/docs/reference/dialogs/requests/) but it seems now the response variable returns two items insead 'to' and 'request'. To being a comma delimited string of user ids and request being a request id. Is this correct? I have seen nothing about this anywhere but it is the behavior I am seeing currently.
Update
Here is a super simplified version of my call:
FB.ui({method: 'apprequests', message: 'My Great Request'}, requestCallback);
function requestCallback(response) {
for(var key in response){
console.log(key);
console.log(response[key]);
}
}
When I make a request to one person the variable response has two keys: request and to. Request is a request id, to is the id of the person I'm sending the request to. If I make a call to the graph api using the provided request id, however, I find that the user under both 'to' and 'from' are equal to the sender's name and fbid.
Alternatively, if I request to multiple people request is equal to a single request id and to is an array containing all the fbids of the users that had requests sent to them. When I make a call to the graph api, however, I once more find that both 'to' and 'from' contain the user id and name of the requesting user.
I faced similar issue yesterday. Had to fix my code. But today request_ids were back in the response. So I updated the code again. But this time to work with both type of objects.
I found the documentation here (move down to the "Performance improvements" section)
http://developers.facebook.com/blog/post/569/
But it still doesn't explains why they reverted the change today. Or was it accidently released yesterday.
As in the documentation, the new callback will receive an object (response) that contains an array (request_ids) of request ids:
{
"request_ids": [
0: [request_id]
1: [request_id]
...
]
}
So I suppose you can loop using this modified code:
function requestCallback(response) {
for( var k in response.request_ids ) {
console.log(k);
console.log(response.request_ids[k]);
}
}
There is already a bug filed here
http://developers.facebook.com/bugs/129565473812085
There is no clear information yet whether the response is really changed or its a bug.
Related
Question: How do I create a subpanel record through the SugarCRM rest api endpoint for accounts?
Steps taken so far:
I've added a new package called, "transactionHistory" with a module named, "InvoiceHistory" using the SugarCRM studio.
I added a One to Many relationship to the Accounts module using studio.
I'm using NetSuite to push new invoices to the new module's record via the subpanel "create" option. Here's the code I'm using:
function createSugarTransaction(transaction, token) {
var url = 'https://crm.techsoft3d.com/rest/v10/Accounts/' + transaction.customer;
var headers = {
"Content-Type": "application/json",
"OAuth-Token": token
};
var now = (new Date()).toISOString();
var body = {transactionHistory_InvoiceHistory:
{
create: [{
name: transaction.docId,
transaction_date_c: transaction.date,
invoice_status_c: transaction.status,
due_date_c: transaction.duedate,
total_amount_c: transaction.total,
amount_due_c: transaction.remaining,
start_date_c: transaction.startdate,
end_date_c: transaction.enddate
}]
}
};
var response = nlapiRequestURL(url, JSON.stringify(body), headers, 'PUT');
return response;
}
The transaction object has been validated and the json object within the create: [] array has matching sugar fields (key) with the corresponding transaction object values.
When making the API call to sugar I'm successfully authenticated and have access to the custom module and accounts - so no problem there. However, when the call is returned to response it's showing the following error:
{"error":"no_method","error_message":"Could not find a route with 1 elements"}
I'm unsure of what else is needed in order for the record to be created. According to sugar's help documentation and developer community this should work. I'm using the basic information provided by sugarcrm support portal:
http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.6/API/Web_Services/Examples/v10/module_POST/
According to other blog posts within the developer community, it should be as simple as adding the subpanel name, followed by an array of fields under the "create" object... similar to this:
var requestBody = { package_module:create[{name:value}]};
My initial thinking of what's wrong is:
1. my package_module name isn't correct, but I'm unable to find it anywhere within the applicaiton or help documentation.
2. the request body isn't formatted properly, even though it's structure was copied from this article https://developer.sugarcrm.com/2014/02/28/sugarcrm-cookbook2/
Any help would be appreciated.
try the createRelatedRecord api endpoint
type {sugarurl}/rest/v10/help to see a list of endpoints to look through, most of which have documentation and examples
https://crm.techsoft3d.com/rest/v10/help
your API url should have the name of the link (relationship) you want, in addition to the values in the POST payload
https://crm.techsoft3d.com/rest/v10/Accounts/{transaction.customer}/link/accounts_transactionhistory (or whatever your link's name is)
per the documentation for this endpoint, you just specify the field values in the payload
{
"first_name":"Bill",
"last_name":"Edwards"
}
I'm currently trying to get an idea of getting Facebook's RSVP for an event, but really stuck on that part:
as I see now, to get user's RSVP I have to make three requests with the following logic:
request eventID/attending/userID ->
if "data" array count == 0 ->
request eventID/maybe/userID ->
if "data" array count == 0 ->
request eventID/declined/userID
else -> means user didn't make any choice previously.
So here it looks like I have to make 3 requests to facebook's graph api to get users's RSVP for a single event.
The question is if there is any way to get an RSVP status for an event doing a single request?
I'm using the latest Facebook SDK and the latest graph api.
Many thanks in advance.
So the best solution here so far is:
one request to /eventID/attending/userID
one request to /eventID/maybe/userID
one request to /eventID/declined/userID (if needed to know if the event invitation was declined)
Call to eventID/attending(maybe/declined)/userID lets us filter rsvp to single user, so we avoid downloading and processing a large amount of data here.
After call you have two options:
If result is true, you get the following response:
{
"data": [
{
"name": "Oleskii Poplavlen",
"id": "10204715567996406",
"rsvp_status": "attending"
}
]}
If result is false, you get the following response:
{
"data": []
}
So while you still have to make multiple requests to get user's RSVP to event, you can avoid downloading loads of other users's rsvps.
Hope that helps someone!
I can get you started to do it in 2 calls:
FB.api('/'+ event_id + '?fields=id,attending{rsvp_status},maybe{rsvp_status}', function(event_response){
// here you should make a call to check if the user has the event and if so get the rsvp_status
FB.api('/'+ user_id + '/events?fields=id,rsvp_status', function(user_response){
// check if user has event, then log the rsvp_status
if(user_response.id == event_response.id) {
console.log(user_response.rsvp_status);
} else {
console.log("user is not going");
});
});
I have not tested this but I've been playing around with this API for quite a while now. This could be an answer to do it in 2 calls, not in 1 unfortunatly.
The first call doesn't need the 'attending' and 'maybe' fields but it's usefull to test with.
I read this article.
So, I tried it and I put a number in the data property.
FB.ui({
method: 'apprequests',
message: 'Come join me and play at MyWebSite!',
data: '12345',
redirect_uri: 'myWebSite'
});
I get the request_ids, but how do I get the data part (the 12345 number)?.
on server side, you can do something like:(using php here)
$request_ids = $_GET['request_ids'];
$request_ids = explode(",", $request_ids);
foreach($request_ids as $request_id)
{
$request_object = $facebook->api($request_id);
if(isset($request_object['data'])) $req_data = $request_object['data']; //$req_data will be '12345' as per your request data set.
// after getting the data, you may like to delete the request.
$full_request_id = $request_id."_".$fbid; //$fbid is current user facebook id
$facebook->api("$full_request_id","DELETE");
}
Did you try Facebook's documentation too?
https://developers.facebook.com/docs/requests/ has more documentation; if a data parameter was added in the call to the requests dialog, the same value should also be there when requesting the Request details via the API (i.e. a call to /REQUEST_ID)
See the facebook developer site documentation for more details
http://developers.facebook.com/docs/reference/dialogs/requests/
Note:
data:Optional, additional data you may pass for tracking. This will be stored as part of the request objects created. The maximum length is 255 characters.
In the context of a given Facebook app, suppose User A invited user B to start using it. Once User B accepts to use the app, is there any way to retrieve the ID of User A programmatically (via either PHP/JS SDK) ? This doesn't seem quite documented.
For what it's worth, A/B users are friends, if it's any use.
when user comes following the app request, you can get request id's using
$_GET['request_ids']
then retrieve all the request ids with which you can call graph api to get the corresponding request details like below:
if(isset($_GET['request_ids']))
{
$request_ids = $_GET['request_ids'];
}
$request_ids = explode(",", $request_ids);
foreach($request_ids as $request_id)
{
$request_object = $facebook->api($request_id);
//this $request_object have sender facebook id in the field uid_from
}
If you look here:
http://developers.facebook.com/docs/reference/dialogs/requests/
You can see the object layout. Of note is the data property:
Optional, additional data you may pass for tracking. This will be
stored as part of the request objects created. The maximum length is
255 characters.
In this object you can add your referring UserId and then when the request is claimed, you can then process it on your end.
Hope this helps.
How can I query full roster using JSJAC XMPP client? I have tried following function for this, but it does not work:
function getRoster(con){
var roster = new JSJaCIQ();
roster.setIQ(null, 'get', 'roster_1');
roster.setQuery(NS_ROSTER);
con.send(roster);
}
Instead of con.send, try:
con.sendIQ(roster, {result_handler: function(aIq, arg) {
var node = aIq.getQuery()
// do something with roster
});
You need to have a callback that fires when the roster is returned. To be complete, set a error_handler as well, in case an IQ error is returned or you time out.
sorry for commenting on such old question, hoewever this pops as #1 result in google on 'JSJAC roster' and the above answers didn't worked for me. i don't know whether something changed in the JSJaC API, however i was receiving iq errors 'service-unavaliable'. i had to use this code instead:
var rosterRequest = new JSJaCIQ();
rosterRequest.setType('get');
rosterRequest.setQuery(NS_ROSTER);
connection.send(rosterRequest);
(so no domain setting and no id setting - just the type, and namespace).