Access Exchange Calendar with Exchange Web Services - ios

I want to build a client where I can display events in a given Exchange Calendar.
I read about ActiveSync and Exchange Web Services, and apparently Exchange Web Services is the way to access the calendars, however, I cannot find any documentation on how to go about fetching the data (i.e. how to authenticate with the Exchange server, how to retrieve the data (through HTTP POST requests?), and so on).
Am I on the right track or am I missing a different API that is used to access an Exchange calendar? I would prefer, if I didn't have to use Apple's Event Kit since that would require the user to sync his account with the iOS device first.

EWS is the way to go. You can read any user's calendar (presuming you have credentials or impersonation authority), and can also subscribe to notifications when a calendar changes. EWS can be accessed from .NET apps, Java, and other languages. Of course the easiest way to go would be using C# and the EWS Managed API, but there are a lot of alternatives outside the Windows world. You can start here, but you'll probably want to search for you specific technology. There's a lot of info out there.

In JAVA EWS api , i used below code:
public static void getAllMeetings() throws Exception {
try {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date startDate = formatter.parse("2016-01-01 00:00:00");
SearchFilter filter = new SearchFilter.IsGreaterThanOrEqualTo(ItemSchema.LastModifiedTime,startDate);
FindItemsResults<Item> findResults = service.findItems(WellKnownFolderName.Calendar, filter, new ItemView(1000));
System.out.println("|------------------> meetings count = " + findResults.getTotalCount());
for (Item item : findResults.getItems())
{
Appointment appt = (Appointment)item;
//appt.setStartTimeZone();
System.out.println("TimeZone====="+appt.getTimeZone());
System.out.println("SUBJECT====="+appt.getSubject());
System.out.println("Location========"+appt.getLocation());
System.out.println("Start Time========"+appt.getStart());
System.out.println("End Time========"+appt.getEnd());
System.out.println("Email Address========"+ appt.getOrganizer().getAddress());
System.out.println("Last Modified Time========"+appt.getLastModifiedTime());
System.out.println("Last Modified Time========"+appt.getLastModifiedName());
System.out.println("*************************************************\n");
}
} catch (Exception exp) {
exp.printStackTrace();
}
}
I can get all meeting schedules.

Related

Send message to self-Chat in Microsoft Teams using Graph API

I'm trying to send a message to my self-Chat in Microsoft Teams through a Graph API call but can't find the ID of this specific chat. For the record, this type of chat was introduced to Teams in June, 2022.
By reading the Graph API documentation, it's possible to list all chats available for a specific user using the following API call (in this case, myself):
[GET] https://graph.microsoft.com/beta/me/chats/
Yet, I can't seem to find my self-chat in there. The chat itself is already created since I wrote messages in it but it doesn't appear in the call response.
I've tried to filter the results by most recent results, by filtering on my own name or by filtering by ChatType, but it was still missing.
Is anyone aware of a way to get the ID of a user self-chat in Microsoft Teams?
Thanks!
Self chat is a special kind, You can use this endpoint to communicate with it:
https://graph.microsoft.com/v1.0/me/chats/48:notes/messages
Hope that helps :)
Answering harrywyn's question regarding the pop up notification, you can set it as unread the same as any chat like this:
EndPoint = f'https://graph.microsoft.com/v1.0/chats/48:notes/markChatUnreadForUser'
update_chat = {
"user": {
"id" : uid,
"tenantId": TENANT_ID
}
}
resp = requests.post(EndPoint, headers=headers, verify=False, json=update_chat)

Error in SharePoint oAuth Authentication using Sharepoint Online CSOM and PnP in .net core

I am trying to make sharepoint authentication using oAuth(Azure AD App) using Sharepoint Online CSOM and PnP, but it gives error "The given key was not present in the dictionary.". I have created Azure AD App and added API permission for Sharepoint AllSite.FullControl in that app.
I am using trial sharepoint tenant.
Here is my code snippets:
ClientContext _sharepointContaxt = null;
string Username = [Username];
string Password = [Password];
string AppId="67b1845e-88b1-4e6c-b7db-7f1d3abe3b06";
Uri site = new Uri([Sharepoint_site_url]);
using (var authenticationManager = new AuthenticationManager("67b1845e-88b1-4e6c-b7db-7f1e3aae3a06"))
using (_sharepointContaxt = authenticationManager.GetContext(site, Username, SecurePassword(Password)))
{
Web web = _sharepointContaxt.Web;
_sharepointContaxt.Load(web);
_sharepointContaxt.ExecuteQuery();
}
I faced the same "The given key was not present in the dictionary." issue whenever I occasionally sent Post request to Azure AD in a for loop. I'm not sure if this failure scenario is as the same as yours.
One of my debug way is to check the dictionary and see which "given key" was lost. In AuthenticationManager class, there is a private method called AcquireTokenAsync. This method is to request Azure AD to return SPO accessing token, and save it as a Json format in variable tokenResult, and then use GetProperty("access_token") to get token.
If Azure AD did not return SPO token for some reason, access_token might not be available in the tokenResult, result in the error code you saw.
In this case, error message in tokenResult help you to see the reason why Azure AD did not return the token.

My android project crashed when I called token.jwt for twilio chat

I am trying to generate access token for twilio chat but got this error:I have been trying to figure out where the error is coming from but can't get it figured out. I will really appreciate your help. Thanks
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.zihron.projectmanagementapp, PID: 16355
java.lang.Error: javax.xml.datatype.DatatypeConfigurationException: Provider org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl not found
at javax.xml.bind.DatatypeConverterImpl.<clinit>(DatatypeConverterImpl.java:744)
at javax.xml.bind.DatatypeConverter.<clinit>(DatatypeConverter.java:78)
at javax.xml.bind.DatatypeConverter.printBase64Binary(DatatypeConverter.java:547)
at io.jsonwebtoken.impl.Base64Codec.encode(Base64Codec.java:24)
at io.jsonwebtoken.impl.Base64UrlCodec.encode(Base64UrlCodec.java:22)
at
io.jsonwebtoken.impl.AbstractTextCodec.encode(AbstractTextCodec.java:31)
at io.jsonwebtoken.impl.DefaultJwtBuilder.base64UrlEncode(DefaultJwtBuilder.java:314)
at io.jsonwebtoken.impl.DefaultJwtBuilder.compact(DefaultJwtBuilder.java:282)
at com.twilio.jwt.Jwt.toJwt(Jwt.java:100)
at ZihronChatApp.token.TokenGenerator.getToken(TokenGenerator.java:34)
at com.zihron.projectmanagementapp.ChatActivity.onCreateView(ChatActivity.java:43)
I have my details below:
public AccessToken getToken() {
// Required for all types of tokens
String twilioAccountSid ="AC601f2c7***7ed***640***264c***d0d";
String twilioApiKey = "SK684***dda***c81****6c4a****093**";
String twilioApiSecret ="96****dbc06****b74d50***b9***3*4";
String serviceSid="IS***a29****e24****5d****4b20**3e*";
String identity = "joshua.hamilton#gmail.com";
ChatGrant grant = new ChatGrant();
grant.setServiceSid(serviceSid);
AccessToken token = new AccessToken.Builder(twilioAccountSid,
twilioApiKey, twilioApiSecret)
.identity(identity).grant(grant).build();
Log.e("++==--",""+token.toJwt());
//.identity(identity).grant(grant);
return token;
}
Twilio developer evangelist here.
The Twilio Java library is not intended for use within Android projects.
The issue here is that you should not be storing your credentials within your application. A malicious user could decompile your application, take your credentials and abuse them.
Instead, you should create a server (or use some sort of serverless environment, like Twilio Functions) that can run this code and return the token. You should then make an HTTP request from your Android application to fetch that token. Check out the Twilio Programmable Chat Android Quickstart to see how it's done there.

OVER_QUERY_LIMIT in simple SPGooglePlacesAutocompleteQuery request

I'm trying to create simple autocomplete UI widget:
self.autocompleteQuery = [[SPGooglePlacesAutocompleteQuery alloc] initWithApiKey:[GlobalConfig sharedInstance].kGoogleBrowserKey];
self.autocompleteQuery.language = kFFAutocompleteQueryLanguage;
self.autocompleteQuery.types = SPPlaceTypeAddress;
self.autocompleteQuery.location = [FFAppDataHelper coordinatesForMoscow];
self.autocompleteQuery.radius = [GlobalConfig sharedInstance].kMoscowRadius;
self.autocompleteQuery.countryCode = #"RU";
Then I want to get all values for input string from UITextField on 'valueChanged' event:
self.autocompleteQuery.input = [streetName stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
[self.autocompleteQuery fetchPlaces:^(NSArray *places, NSError *error) {
[self loaderStopAnimating];
if (places) {
//do some stuff
} else {
FFError *detectedError = [FFError errorWithNSError:error];
[self showErrorMessage:[detectedError errorMessage]];
}
}];
So when I type 'k' I get response with streets and if I add next char to my text field I receive OVER_QUERY_LIMIT every time. I've tried it on simulator and devices with the same result. And it starts working again after 10-20 sec. I don't use loops or smth similar, I just want to get suggestions for input string in real time, but I can't get it because of error. What should I do to avoid it?
For the web service request, use a key.
Follow this :https://developers.google.com/maps/documentation/geocoding/start#api_key
Doc says:
Note: Maps for Work users must include client and signature parameters with their requests instead of a key.
All Geocoding API applications should use an API key. Including a key in your request:
Allows you to monitor your application's API usage in the Google Developers Console. Enables per-key instead of per-IP-address quota limits. Ensures that Google can contact you about your application if necessary. The Geocoding API uses an API key to identify your application. API keys are managed through the Google APIs console. To create your key:
Visit the APIs console at Google Developers Console and log in with your Google Account. Click the Services link from the left-hand menu in the APIs Console, then activate the Geocoding API service. Once the service has been activated, your API key is available from the API > Access page, in the Simple API Access section. Geocoding API applications use the Key for server apps. To specify a key in your request, include it as the value of a key parameter.
Note: By default, a key can be used from any server. We strongly recommend that you restrict the use of your key by IP address to servers that you administer. You can specify which IP addresses are allowed to use your API key by clicking the Edit allowed referers... link in the API console.
Note: HTTPS is enforced for requests that include an API key.

api for zip +4 from an address

What's the best api/resource to get a zip +4 from an address?
I don't want something that needs to be downloaded and updated from time to time; I want one that's updated automagically.
The goal is to look up state and federal officials without getting "duplicate" positions.
have you tried Google Maps JavaScript API V3
UPDATED:
in responce to your comment
this is easy as count 1, 2 , 3 ;)
take a look at this:
http://maps.google.com/maps/api/geocode/json?address=Winnetka&sensor=false
you need to looking for google map geocoding service! ( Viewport Biasing )
http://code.google.com/intl/it-IT/apis/maps/documentation/geocoding/
example code would be:
using jQuery
$(function() {
$.getJSON("http://maps.google.com/maps/api/geocode/json?address=Winnetka&sensor=false",
function(data) {
var zip_code = data.results[0].long_name;
alert(zip_code);
});
});
Yahoo has a zip + 4 in thier API, limit 5000 request per day.
Yahoo GeoCoding
The USPS has an API for finding/checking zip codes (among other things).
http://www.usps.com/webtools/address.htm
I've used Endicia at past jobs. It is a network HTTP-based API. (I can't remember if it was SOAP or REST.)
Apple provide brilliant facility to get zip+4code from lattitude and longitude with reverse geocoder -
- (void)getPlaceMarkInfo
{
CLLocationCoordinate2D coordinate;
coordinate.latitude = your lattitude;
coordinate.longitude = your longitude;
MKReverseGeocoder *RevGeoCoder = [[MKReverseGeocoder alloc] initWithCoordinate:coordinate];
RevGeoCoder.delegate = self;
[RevGeoCoder start];
}
#pragma mark MKReverseGeocoderDelegate:
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
{
NSLog(#"YOUR STATE IS - %#",[placemark.addressDictionary valueForKey:#"State"]);
NSDictionary *dictAddress = placemark.addressDictionary;
NSString *strZipPlus4Code = [NSString
stringWithFormat:#"%#-%#",[dictAddress valueForKey:#"ZIP"],
[dictAddress valueForKey:#"PostCodeExtension"]];
strStateName = [placemark.addressDictionary valueForKey:#"State"];
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
{
NSLog(#"REVERSE GEOCODER FAILED");
}
Previous answers have included some really good information, most importantly:
USPS API can only be used if you're shipping through USPS (from their terms of service: "User agrees to use the USPS Web site, APIs and USPS data to facilitate USPS shipping transactions only.")
ZIP Codes are adjusted/updated fairly frequently, so it would be important to have the most current data. (More info about how often to re-validate your addresses here)
You also said you want something that doesn't need to be installed and kept updated.
With those qualifications in mind, I would suggest LiveAddress API. It's a cloud-based, automatically updated API that returns, among over 40 other datapoints, ZIP+4 data on your addresses. It can handle thousands of addresses per second, so it's super-fast and easy to use. If you have a list of address you want to work though (rather than one at a time), you might want LiveAddress for Lists, which lets you upload and process a whole list at once.
Disclosure: I work at SmartyStreets, the company that provides LiveAddress.
In reference of Yahoo BOSS GEO Api:
http://yboss.yahooapis.com/geo/placefinder?location=170+South+Market+St.,+San+Jose,+CA
Make a GET request with following authorization HEADER
Example of using OAuth in HTTP Header:
Authorization: OAuth realm="http://yboss.yahooapis.com/",oauth_consumer_key="dj0yJmk9QnFUYVRUSWtRZEhsJmQ9WVdrOVFrYzFja2x4TkdNbWNHbzlNVEExTWpFMk1ESTJNZy0tJnM9Y29uc3VtZXJzZWNyZXQmeD1lNA--",oauth_nonce="ZDQDDVLFCWKCZ0BD",oauth_signature_method="HMAC-SHA1",oauth_timestamp=" 1367827192",oauth_version="1.0",oauth_signature="phP2dNiCmvwpK4M6G%2F85KnnvTXo%3D"
where:
Authentication for BOSS Geo queries requires OAuth information in the HTTP header OR through parameters in the GET request. There are six elements that are required for authorization:
oauth_version=1.0 – The standard of OAuth supported by BOSS Geo.
oauth_timestamp= – The timestamp is expressed in the number of seconds since January 1, 1970 00:00:00 GMT. The timestamp value MUST be a positive integer and MUST be equal to or greater than the timestamp used in previous requests. The timestamp can be reused for up to 5 minutes. Important: After 5 minutes a fresh timestamp must be supplied.
oauth_nonce – is a random string, uniquely generated for all requests for a specific timestamp. This helps verify that a request has never been made before and helps prevent replay attacks when requests are made over a non-secure channel (such as HTTP).
oauth_consumer_key= – obtained from YDN during the BOSS project registration process. This is unique to the developer. Please follow the directions on the displayed key page and copy the entire key from YDN. If you do not copy the entire key, this results in a "Consumer Key rejected" error.
oauth_signature_method=HMAC-SHA1 – (specific algorithm used for BOSS OAuth calls).
oauth_signature – can be generated by an OAuth library. A list of supported OAuth libraries is available here: http://oauth.net/code. Over a dozen languages are supported.
You will get zip+4 code in Response under "postalcode" key.

Resources