I am trying to create an event in my app but keep getting this 'Invalid parameter' error:
(OAuthException - #100) (#100) Invalid parameter
when it hits:
JsonObject result = facebookClient.Post("/me/events", createEventParameters) as JsonObject;
Changed the parameters several times but still no help, anyone can advice:
public string CreateEvent()
{
var accessToken = accessTok;
FacebookClient facebookClient = new FacebookClient(accessToken);
Dictionary<string, object> createEventParameters = new Dictionary<string, object>();
createEventParameters.Add("owner", "Me");
createEventParameters.Add("name", "Test Event");
createEventParameters.Add("description", "This is a test event.");
createEventParameters.Add("start_time", DateTime.Now.AddDays(2).ToUniversalTime().ToString());
createEventParameters.Add("end_time", DateTime.Now.AddDays(2).AddHours(4).ToUniversalTime().ToString());
createEventParameters.Add("location", "A Street");
// Sample venue
JsonObject venueParameters = new JsonObject();
venueParameters.Add("street", "19 Phipps St");
venueParameters.Add("city", "Toronto");
venueParameters.Add("state", "ON");
venueParameters.Add("zip", "L2A 2V2");
venueParameters.Add("country", "Canada");
venueParameters.Add("latitude", "43.6654507");
venueParameters.Add("longitude", "-79.38569580000001");
createEventParameters.Add("venue", venueParameters);
createEventParameters.Add("privacy", "SECRET");
createEventParameters.Add("updated_time", DateTime.Now.ToString());
//Add the event logo image
FacebookMediaObject logo = new FacebookMediaObject()
{
ContentType = "image/png",
FileName = #"D:/Downloads/bb.png"
};
logo.SetValue(File.ReadAllBytes(logo.FileName));
createEventParameters[#"D:/Downloads/bb.png"] = logo;
JsonObject result = facebookClient.Post("/me/events", createEventParameters) as JsonObject;
return result["id"].ToString();
}
Ok happens that I have an invalid date format. For FB docs:
NOTE - After the 'Events Timezone' migration, all event times are ISO-8601 formatted strings; they can no longer be specified as timestamps. The following formats are accepted:
Date-only (e.g., '2012-07-04'): events that have a date but no specific time yet.
Precise-time (e.g., '2012-07-04T19:00:00-0700'): events that start at a particular point in time, in a specific offset from UTC. This is the way new Facebook events keep track of time, and allows users to view events in different timezones.
Related
ApiClient apiClient = new ApiClient("https://demo.docusign.net/restapi");
List<string> scopes = new List<string>
{
OAuth.Scope_SIGNATURE,
OAuth.Scope_IMPERSONATION
};
docuSign_JWT testConfig = new docuSign_JWT();
testConfig.ApiClient = new ApiClient(testConfig.Host);
// If this is the first time logging in - Get Consent from the user - this is a onetime step.
Uri oauthURI = testConfig.ApiClient.GetAuthorizationUri(testConfig.IntegratorKey, scopes, RedirectURI, OAuth.CODE, "testState");
Process.Start(oauthURI.ToString());
var privateKeyStream = System.Text.Encoding.UTF8.GetBytes(File.ReadAllText(testConfig.PrivateKeyFilename));
OAuth.OAuthToken tokenInfo = testConfig.ApiClient.RequestJWTUserToken(testConfig.IntegratorKey, testConfig.UserId, testConfig.OAuthBasePath, privateKeyStream, testConfig.ExpiresInHours);
apiClient = new ApiClient("https://demo.docusign.net/restapi");
apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + tokenInfo.access_token);
EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();
envelopeDefinition.EmailSubject = "Please sign this document";
envelopeDefinition.TemplateId = "***************";
DocuSign.eSign.Model.TemplateRole cc1 = new DocuSign.eSign.Model.TemplateRole();
cc1.Email = "Email1 default template recipient";
cc1.Name = "Name";
cc1.RoleName = "Staff";
DocuSign.eSign.Model.TemplateRole cc2 = new DocuSign.eSign.Model.TemplateRole();
cc2.Email = "Email2 new email ID";
cc2.Name = "Name2";
cc2.RoleName = "Staff";
DocuSign.eSign.Model.TemplateRole cc3 = new DocuSign.eSign.Model.TemplateRole();
cc3.Email = "Email3 new Email ID";
cc3.Name = "Name3";
cc3.RoleName = "Staff";
List<DocuSign.eSign.Model.TemplateRole> templateRoles = new List<DocuSign.eSign.Model.TemplateRole>();
templateRoles.Add(cc1);
templateRoles.Add(cc2);
templateRoles.Add(cc3);
envelopeDefinition.TemplateRoles = templateRoles;
envelopeDefinition.Status = "sent";
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(ConfigurationManager.AppSettings["accountID"], envelopeDefinition);
Above is my code to send docuSign template document. But only default recipient get document with fields, other recipient get only pdf file without fields.
How to send template document with fields to all recipient.
below is template fields img
Thank you
enter image description here
It looks like all three of your recipients have the same RoleName, which means there's going to be an issue mapping each recipient to their role.
Template Role Names should be unique, and their definition in the API call need to match exactly what is present in the template. When setting up roles to be populated by through the API, it's also important to make sure that only the RoleName field is filled out. If a template has a "burned in" name and email address, you won't be able to populate them in your API call.
Can you grab a screenshot of how the recipients are set up on the template in the web console? Like this:
I'm new to Twitter API & trying to get tweets with a specific hashtag in my C# Web application.
I was able to authenticate my app & get JSON from Twitter ,here are some questions/issues I have:
API can only return maximum 100 tweets in one call,so how I can check if I've more tweets?
If somebody have code example to convert that(Twitter's) JSON into custom class object,so
I can count tweets (I tried but getting errors)?
I used this to generate c# classes from json & getting error while doing following:
JavaScriptSerializer json_serializer = new JavaScriptSerializer();
RootObject routes_list = (RootObject)json_serializer.DeserializeObject(s);
Tweetinvi manages that for you. Here is an example returning 200 results.
var searchParameter = Search.GenerateSearchTweetParameter("#my_tag");
searchParameter.Lang = Language.English;
searchParameter.SearchType = SearchResultType.Popular;
searchParameter.MaximumNumberOfResults = 200;
searchParameter.Since = new DateTime(2013, 12, 1);
// ... There are many different parameters that can be set
var tweets = Search.SearchTweets(searchParameter);
tweets.ForEach(t => Console.WriteLine(t.Text));
// Get number of objects
var nbTweets = tweets.Count();
Hope this helps.
Certainly Tweetinvi as user64 said, is a great API, please for version 2.1 the following does the job. Be aware of set RateLimitTrack mode
// Set up my credentials in (https://apps.twitter.com)
Auth.SetUserCredentials(consumer_key, consumer_secret, access_token, access_token_secret);
// Enable Automatic RateLimit handling
RateLimit.RateLimitTrackerMode = RateLimitTrackerMode.TrackAndAwait;
var searchParameter = Search.CreateTweetSearchParameter("#My_Tag");
searchParameter.Lang = LanguageFilter.Spanish; // or English
searchParameter.SearchType = SearchResultType.Recent;
searchParameter.MaximumNumberOfResults = 200; // or any number
searchParameter.Since = new DateTime(2013, 12, 1);
var tweets = Search.SearchTweets(searchParameter); // tweets.Count() has the actual searched tweets
foreach(var item in tweets)
{
// do anything with item and its properties example: item.Text;
}
I have a Debugging Official Account with WeChat. I have entered my public URL and Token into the field provided http://admin.wechat.com/debug/sandbox and also attempted debugging the request with http://admin.wechat.com/debug/
My ASP.Net [.Net4.5] Web API application's POST Method looks like the following :
public HttpResponseMessage PostMessage([FromBody]Strikemedia.Api.WeChat.TextMessage value)
{
if (value == null)
{
var richMediaMessage = new RichMediaMessage();
richMediaMessage.touser = value.FromuserName;
//Create Article
var item = new Article()
{
title = "Didn't receive anything back",
description = "Mind entering 'test'",
picurl = "URL",
url = "URL"
};
var articles = new List<Article>();
articles.Add(item);
richMediaMessage.articles = articles;
richMediaMessage.articleCount = articles.Count;
return Request.CreateResponse(HttpStatusCode.OK, richMediaMessage, "application/json");
}
var exploded = value.Content.Split(' ')[0];
var richMedia = new RichMediaMessage();
richMedia.touser = value.FromuserName;
//Create Article
var article = new Article() {
title = response.KeywordDescription,
description = response.Response,
picurl = "URL",
url = "URL"
};
var _articles = new List<Article>();
_articles.Add(article);
richMedia.articles = _articles;
richMedia.articleCount = _articles.Count;
//Return response
var resp = Request.CreateResponse(HttpStatusCode.OK, richMedia, "application/json");
//resp.RequestMessage.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
return resp;
}
It needs to respond with a RichMessageType in JSON format and is received in XML format
Am i missing something or have i overlooked something?
Can you confirm that you have submitted the URL and token into admin.wechat.com and that the URL and token was accepted?
Also note you get XML and you respond with XML no json response.
Have you had a look at: http://youtu.be/kB20Zf51QWU
And then this
http://youtu.be/_2FSzD2B2F0
This is the documentation for the XML can be found when you google "wechat guide to message api"
So if you still not receiving a success message when submitting your app on admin.wechat.com then you can send me your test URL here. To find this URL check your access logs to see exactly what URL wechat is calling. Then post it here. Please note that when you hit the URL as wechat will you should only see the "echostr" printed on the screen (when viewing the source in your browser). No XML no HTML just the echostr.
Also make sure there are no spaces or newlines after or before the "echostr". When you view the source it should only be one line which is the echostr GET param's value.
The XML response only comes in later when you actually start responding to messages from users. For now Wechat is just confirming if your security is setup correctly.
Also note if your server is load balanced you will have to skip the signature validation and build your own validation when a echostr GET parameter gets passed through and only echo the "echostr" param to screen.
I am getting an invalid ModelState when data is returned from a View using an ajax call but only for edits. I am passing a datetime value from a SQL record to the view. The date shows up just fine in a Kendo UI DateTime picker. If I make a new selection from the datetime picker, I don't get the exception, it's only if I don't make any changes do I get the invalid error. Here is what the MVC controller is showing:
The value '/Date(1387443600000)/' is not valid for RequiredByDate."
What am I missing here? First time I have ever had an issue with a datetime field like this.
EDIT: Found out the date was being formatted in the view once the controller passed it in. Here is what I had to do before using it on the page and eventually sending it back to the controller (code is verbose for debugging purposes):
var myModel = model;
var jsonDate = myModel.Header.RequiredByDate; // "/Date(1387443600000)/"
var value = new Date(parseInt(jsonDate.substr(6)));
var ret = value.getMonth() + 1 + "/" + value.getDate() + "/" + value.getFullYear();
//ret is now in normal date format "12-13-2013"
After posting an edit above I found what I think is an even better solution to the problem. Here is a function that converts the string to an actual date object:
function dateFromStringWithTime(str) {
var match;
if (!(match = str.match(/\d+/))) {
return false;
}
var date = new Date();
date.setTime(match[0] - 0);
return date;
}
I have the following code for use in my asp.net website:
CalendarService service = new CalendarService("mycalendar");
EventQuery query = new EventQuery();
query.Uri = new Uri(group.GroupEventsURL);
query.SingleEvents = true;
query.SortOrder = CalendarSortOrder.ascending;
query.ExtraParameters = "orderby=starttime";
query.NumberToRetrieve = 50;
query.TimeZone = "America/Chicago";
EventFeed feed = service.Query(query);
Which produces the following URL:
http://www.google.com/calendar/feeds/TRIMMEDgroup.calendar.google.com/private-TRIMMED/full?max-results=50&orderby=starttime&ctz=America%2FChicago&sortorder=ascending&singleevents=true
According to the documentation (emphasis mine), I expect the Times in each EventEntry to be in the Central time zone:
ctz: The current timezone. If not specified, times are returned in the calendar time zone.
Times in the resulting feed will be represented in this timezone.
Replace all spaces with underscores (e.g. "ctz=America/Los_Angeles").
But my server is hosted in Arizona, so (for now) all of the dates on the calendar are two hours earlier than they should be. Am I doing something wrong? How do I get the dates in the feed to be in the Central time zone even though the server is in Arizona?
I do not plan on moving my hosting any time soon, but since Arizona does not participate in Daylight Savings Time, I cannot simply add two hours to every date.
Don't fight it. The Google.GData.Calendar library sets each time to the system's local time. Here's what I could dig up about it.
You'll need to convert all those times from every EventEntry
DateTime offsetStartTime = GetTimeZoneOffset(entry.Times[0].StartTime, "Mountain Standard Time");
public static DateTime GetTimeZoneOffset(DateTime dt, string win32Id)
{
var timeUtc = dt.ToUniversalTime();
TimeZoneInfo cstZone = TimeZoneInfo.FindSystemTimeZoneById(win32Id);
DateTime cstTime = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, cstZone);
return cstTime;
}
I am still open to other ideas, but here is what I got to work. I created my own CalendarService class, which converts the dates from:
2010-10-13T18:30:00.000-05:00
to:
2010-10-13 18:30:00
These dates are then converted to the same (and correct) DateTime in any time zone.
internal class CalendarService2 : CalendarService
{
public CalendarService2(string applicationName) : base(applicationName) { }
public new EventFeed Query(EventQuery feedQuery)
{
EventFeed feed = new EventFeed(feedQuery.Uri, this);
using (Stream input = base.Query(feedQuery.Uri, DateTime.MinValue))
{
XmlDocument doc = new XmlDocument();
doc.Load(input);
XmlNodeList nodes = doc.SelectNodes("(//#startTime|//#endTime)[contains(.,'.000-')]");
foreach (XmlNode node in nodes)
{
node.Value = node.Value.Remove(node.Value.Length - 10).Replace('T', ' ');
}
using (MemoryStream output = new MemoryStream())
{
doc.Save(output);
output.Position = 0;
feed.NewAtomEntry += new FeedParserEventHandler(this.OnParsedNewEntry);
feed.NewExtensionElement += new ExtensionElementEventHandler(this.OnNewExtensionElement);
feed.Parse(output, AlternativeFormat.Atom);
}
}
return feed;
}
}