How to specify language, location and city with facebook graph api - facebook-graph-api

I am using FacebookGraphAPIDesktop.swc api to create unpublished post.
How can I assign language, location and city parameter with it?
Currently I am creating it like below :-
var params:Object = new Object();
params.access_token = PhotoToken;
params.published = 0;
params.message = "Test unpublished post";
FacebookDesktop.api("/" + PageID +"/feed", StatusPosted, params,"POST");
thanks in advance

I found the solution and posting here if anyone needs it :-
We need to pass it as a json string :-
var targeting:String = "{'countries':['US','IN']}";
_params.access_token = token;
_params.published = 0;
_params.message = "This is status message 5";
_params.targeting = targeting;
FacebookDesktop.api("/202387076493582/feed", messagePosted1, _params,"POST");

Related

SOAP Fault when Using DocuSign API with Salesforce for Creating Envelope with Templates

I am using Salesforce with DocuSign to try and create an envelope via templates.
DocuSignAPI.EnvelopeTemplates templates = soapService.requestTemplates(accountId, false);
String templateId = templates.EnvelopeTemplateDefinition[0].TemplateID;
DocuSignAPI.EnvelopeTemplate template = soapService.requestTemplate(templateId, false);
DocuSignAPI.EnvelopeInformation envelopeInformation = new DocuSignAPI.EnvelopeInformation();
envelopeInformation.Subject = 'XXXXXXXXXXX';
envelopeInformation.AccountId = accountId;
envelopeInformation.EmailBlurb = 'XXXXXXXXXXXXX';
DocuSignAPI.TemplateReference templateReference = new DocuSignAPI.TemplateReference();
templateReference.RoleAssignments = new DocuSignAPI.ArrayOfTemplateReferenceRoleAssignment();
templateReference.Template = template.EnvelopeTemplateDefinition.TemplateID;
templateReference.TemplateLocation = 'Server';
DocuSignAPI.Recipient recipient = new DocuSignAPI.Recipient();
recipient.ID = currentRecipientIndex + 1;
recipient.Type_x = 'Signer';
recipient.Email = 'XXXXXXXXXXXXXXXX';
recipient.UserName = 'XXXXXXXXXXXXXXXXX';
recipient.RoutingOrder = 1;
DocuSignAPI.ArrayOfRecipient1 recipients = new DocuSignAPI.ArrayOfRecipient1();
recipients.Recipient = new DocuSignAPI.Recipient[1];
recipients.Recipient.add(recipient);
DocuSignAPI.TemplateReferenceRoleAssignment trra = new DocuSignAPI.TemplateReferenceRoleAssignment();
trra.RoleName='Stake holder';
trra.RecipientID = recipient.ID;
templateReference.RoleAssignments.RoleAssignment = new DocuSignAPI.TemplateReferenceRoleAssignment[1];
templateReference.RoleAssignments.RoleAssignment.add(trra);
DocuSignAPI.ArrayOfTemplateReference arrayOfTemplateReference = new DocuSignAPI.ArrayOfTemplateReference();
arrayOfTemplateReference.TemplateReference = new DocuSignAPI.TemplateReference[1];
arrayOfTemplateReference.TemplateReference.add(templateReference);
DocuSignAPI.EnvelopeStatus status = soapService.createEnvelopeFromTemplates(arrayOfTemplateReference, recipients, envelopeInformation, true);
However, upon running the code, I get the following error:
Web service callout failed: WebService returned a SOAP Fault: Unspecified_Error faultcode=soap:Server faultactor=https://demo.docusign.net/api/3.0/dsapi.asmx
And this references the DocuSignAPI where the WebServiceCallout is invoked. Given the ambiguity of the error, I would appreciate any thoughts on what could be causing this.
As an update to this post, I was able to find the error. The indexing for Apex starts at 0 not 1 (unlike MatLab which is what caused my confusion). Because I was starting at index 1, the XML request was passing 'null' values at the 0th index, causing the error. Starting at 0, removed the null values from the XML and the request went through.

Invoking AX web service via C#

I am trying to connect to the AX web services. What I will do it to fetch the right price given a product and a customer.
I realised the right webservice to use is PriceListServiceClient and I am able to log in to it using windows authentication, but I cannot retrieve any data from it.
Here is my code:
PriceListServiceClient priceListServiceClient = new PriceListServiceClient();
priceListServiceClient.ClientCredentials.Windows.ClientCredential.UserName = "yyy";
priceListServiceClient.ClientCredentials.Windows.ClientCredential.Password = "zzz!";
priceListServiceClient.ClientCredentials.Windows.ClientCredential.Domain = "xxx";
CriteriaElement[] criteriaElement = new CriteriaElement[1];
criteriaElement[0] = new CriteriaElement();
criteriaElement[0].DataSourceName = "SalesPrice";
criteriaElement[0].FieldName = "ItemId";
criteriaElement[0].Operator = Operator.NotEqual;
criteriaElement[0].Value1 = "5637153175";
QueryCriteria queryCriteria = new QueryCriteria();
queryCriteria.CriteriaElement = criteriaElement;
CallContext callContext = new CallContext();
var found = priceListServiceClient.find(callContext, queryCriteria);
Console.WriteLine(found.Currency);
priceListServiceClient.Close();
Any idea about why this is happening?
Try filling in the properties in the CallContext (company and language).
new CallContext { Company = "zzz", Language = "nl" };
I found the answer here: http://community.dynamics.com/ax/f/33/p/118741/246784.aspx
The Ax class for Price List document is AxPriceDiscTmpPrintout Class. This class wraps the TmpPriceDiscPrintout table, which is a TMP table. That's why you are not getting anything in return.

gettin error message each time with face book desktop api

I am using FacebookGraphAPIDesktop.swc api to create unpublished post.
How can I assign language, location and city parameter with it?
I tried like below, but getting error "(#100) targeting must only contain one or more of countries,regions,cities,locales"
_params.access_token = token;
_params.published = 0;
_params.message = "This is status message for af_ZA 3";
_params.targeting="countries=US";
FacebookDesktop.api("/202387076493582/feed", messagePosted1, _params,"POST");
Thanks in advance.
I found the solution and posting here if anyone needs it :-
We need to pass it as a json string :-
var targeting:String = "{'countries':['US','IN']}";
_params.access_token = token;
_params.published = 0;
_params.message = "This is status message 5";
_params.targeting = targeting;
FacebookDesktop.api("/202387076493582/feed", messagePosted1, _params,"POST");

Select new to create complex object with nested new throws cast exception

Has anyone had this issue? I am trying to get objects from the database and create a complex poco but I get a cast issue.
The Account property on the poco message type is a poco account type and it will tell me that whatever the first field type is can't be cast to PocoAccount, so in the example below, AccountID is an int so i'll get int cant' be cast to PocoAccount.
var result = (from a in DbAccount.All()
join m in DbMessage.All() on m.AccountID equals a.AccountID
select new PocoMessage {
Account = new PocoAccount {
AccountID = a.AccountID,
FirstName = a.FirstName,
LastName = a.LastName
},
MessageID = m.MessageID,
Subject = m.Subject,
Body = m.Body
});
If found a similar post that suggested using ToList() which seems to fix the issue however it doesn't feel quite right and I haven't checked out the sql consequence.
var result = (from a in DbAccount.All().ToList()
join m in DbMessage.All().ToList() on m.AccountID equals a.AccountID
select new PocoMessage {
Account = new PocoAccount {
AccountID = a.AccountID,
FirstName = a.FirstName,
LastName = a.LastName
},
MessageID = m.MessageID,
Subject = m.Subject,
Body = m.Body
});

SharePoint web services: test if file exists

I'm using SharePoint web services in C#. I have my code working to check files and check them out using the Lists web service. I need to test to see if a file exists; I can find lots of examples for doing this using the object model API, but I can't seem to find a straightforward way of doing this using web services.
Try the Lists.GetListItems with a suitable CAML query.
A CAML query like
<Query><Where><Eq><FieldRef Name="FileLeafRef" /><Value Type="Text">Filename.rtf</Value></Eq></Where></Query>
should work; the field 'FileLeafRef' is where the filename is stored.
This code may do, it's a little rough, but demonstrates how to get a list of files based on the title.
public static bool PageExists(string listName, string webPath, string pageTitle)
{
string pageId = "";
IntranetLists.Lists lists = new IntranetLists.Lists();
lists.UseDefaultCredentials = true;
lists.Url = webPath + "/_vti_bin/lists.asmx";
XmlDocument doc = new XmlDocument();
doc.LoadXml("<Document><Query><Where><Contains><FieldRef Name=\"Title\" /><Value Type=\"Text\">" + pageTitle + "</Value></Contains></Where></Query><ViewFields /><QueryOptions /></Document>");
XmlNode listQuery = doc.SelectSingleNode("//Query");
XmlNode listViewFields = doc.SelectSingleNode("//ViewFields");
XmlNode listQueryOptions = doc.SelectSingleNode("//QueryOptions");
Guid g = GetWebID(webPath);
XmlNode items = lists.GetListItems(listName, string.Empty, listQuery, listViewFields, string.Empty, listQueryOptions, g.ToString());
}
return items.Count > 0;
}
public static XmlNodeList XpathQuery(XmlNode xmlToQuery, string xPathQuery)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlToQuery.OuterXml);
XmlNamespaceManager mg = new XmlNamespaceManager(doc.NameTable);
mg.AddNamespace("sp", "http://schemas.microsoft.com/sharepoint/soap/");
mg.AddNamespace("z", "#RowsetSchema");
mg.AddNamespace("rs", "urn:schemas-microsoft-com:rowset");
mg.AddNamespace("y", "http://schemas.microsoft.com/sharepoint/soap/ois");
mg.AddNamespace("w", "http://schemas.microsoft.com/WebPart/v2");
mg.AddNamespace("d", "http://schemas.microsoft.com/sharepoint/soap/directory");
return doc.SelectNodes(xPathQuery, mg);
}
I also had similiar problems with this.
I have tried the following FieldRefs without success: "Name", "FileLeafRef" and "LinkFilenameNoMenu".
The post located at http://www.johanolivier.blogspot.com details what I had to do to get it working.