How do I fetch a contact's email address? - php

I am using the contact example from the Google OAuth API. I am not getting the contact's email address. I need contact's email address for sending an invitation request. What am I doing wrong?

You need to request access to the scope: https://www.googleapis.com/auth/userinfo.email. Once you have permission, then you send an authorized request to: https://www.googleapis.com/oauth2/v2/userinfo. You will receive back a response with the email address:
{
"email": "<myname>#gmail.com",
"verified_email": true
}
NOTE: If you want to access the rest of the profile, you need to add to the scope with: https://www.googleapis.com/auth/userinfo.profile. Then the same request will return the full profile with email address:
{
"id": "<myID>",
"email": "<myemail>#gmail.com",
"verified_email": true,
"name": "<my name>",
"given_name": "<first>",
"family_name": "<last>",
"link": "https://plus.google.com/<myID>",
"picture": "https://lh4.googleusercontent.com/<pic link>/photo.jpg",
"gender": "male",
"birthday": "<YYYY-MM-DD>",
"locale": "en-US"
}

Related

Error: Cannot handle token prior to 2022-11-25T22:41:29+0530

my server timezone is London and we are in Indian standard Time, everything works fine, except when the jwt and refresh token both expires, I have a scenario where I have to generate a new refresh token with 1 hr validity and supply for the final execution to happen for my mobile app to sync all the data from mobile app to the server.
I am getting this error
Error: Cannot handle token prior to 2022-11-25T22:41:29+0530"
when i check it on postman it works fine but when it run from the mobile app it gives error
JWT Payload Data
{ "iss": "website address", "iat": 1669273766, "nbf": 1669273776, "exp": 1669273826, "aud": "myusers", "data": { "id": 1, "mobilenumber": "XXXXXXXXXXX", "email": "XXXXX#XXX.com", "deviceimeino": "XXXXXXXX", "deveventid": xxxx, "eventexpirydate": { "date": "2022-11-24 23:59:59.000000", "timezone_type": 3, "timezone": "Asia/Calcutta" } } }
Refresh Token Payload Data
{ "iss": "website address", "iat": 1669436131, "nbf": 1669436141, "exp": 1669439727, "aud": "myusers", "data": { "id": 1, "mobilenumber": "xxxxxx", "email": "xxxx#xxx.com", "deviceimeino": "xxxxxxx", "deveventid": xxx, "eventexpirydate": "2022-11-03 23:59:59" } }

Send Current URL link to A Discord Webhook

So, basically I need a way to send the current URL link to A Discord webhook.
So for example, the URL would be https://www.example.com and I need that link to send to my Discord webhook.
Is there any way someone could help me with this? If this is not possible, are there any alternative methods?
I would recommend you first reading this—it explains in detail how to format the payload so that it renders as a message in Discord properly, you can even use markdown!
Second, I'm not sure what language you want to code this in, but here's a simple example using Python and httpx
The idea to take away here is
Pick a client library
Study the Discord webhook message format
Create a client for HTTP
Set the logic to send the payload to the webhook you want
Create and send the payload with the formatted webhook message in a POST request
data = {
"username": "Webhook",
"avatar_url": "https://i.imgur.com/4M34hi2.png",
"content": "Text message. Up to 2000 characters.",
"embeds": [
{
"author": {
"name": "Birdie♫",
"url": "https://www.reddit.com/r/cats/",
"icon_url": "https://i.imgur.com/R66g1Pe.jpg"
},
"title": "Title",
"url": "https://google.com/",
"description": "Text message. You can use Markdown here. *Italic* **bold** __underline__ ~~strikeout~~ [hyperlink](https://google.com) `code`",
"color": 15258703,
"fields": [
{
"name": "Text",
"value": "More text",
"inline": true
},
{
"name": "Even more text",
"value": "Yup",
"inline": true
},
{
"name": "Use `\"inline\": true` parameter, if you want to display fields in the same line.",
"value": "okay..."
},
{
"name": "Thanks!",
"value": "You're welcome :wink:"
}
],
"thumbnail": {
"url": "https://upload.wikimedia.org/wikipedia/commons/3/38/4-Nature-Wallpapers-2014-1_ukaavUI.jpg"
},
"image": {
"url": "https://upload.wikimedia.org/wikipedia/commons/5/5a/A_picture_from_China_every_day_108.jpg"
},
"footer": {
"text": "Woah! So cool! :smirk:",
"icon_url": "https://i.imgur.com/fKL31aD.jpg"
}
}
]
}
import httpx # pip install httpx, or poetry add httpx
with httpx.Client() as client:
request = client.post("https://www.discordwebhook.com", data=data) # needs to be a POST
print(request.status_code)

How to get an email address and other info like name and phone together after getting access token LinkedIn signup API with PHP

I am able to gent email using https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~)) and able to get name and profile pic using https://api.linkedin.com/v2/me.My question is that how can i get it together.Is there any single API to call and get all profile info together?
The documentation says something about lite and basic profile permissions but unfortunately there doesn't seem to be a way to get both in one query.
Profile Json Response:
{
"firstName":{
"localized":{
"en_US":"Bob"
},
"preferredLocale":{
"country":"US",
"language":"en"
}
},
"localizedFirstName": "Bob",
"headline":{
"localized":{
"en_US":"API Enthusiast at LinkedIn"
},
"preferredLocale":{
"country":"US",
"language":"en"
}
},
"localizedHeadline": "API Enthusiast at LinkedIn",
"vanityName": "bsmith",
"id":"yrZCpj2Z12",
"lastName":{
"localized":{
"en_US":"Smith"
},
"preferredLocale":{
"country":"US",
"language":"en"
}
},
"localizedLastName": "Smith",
"profilePicture": {
"displayImage": "urn:li:digitalmediaAsset:C4D00AAAAbBCDEFGhiJ"
}
}
Contact Json Response:
{
"elements": [
{
"handle": "urn:li:emailAddress:3775708763",
"handle~": {
"emailAddress": "ding_wei_stub#example.com"
},
"primary": true,
"type": "EMAIL"
},
{
"handle": "urn:li:phoneNumber:6146249836070047744",
"handle~": {
"phoneNumber": {
"number": "158****1473"
}
},
"primary": true,
"type": "PHONE"
}
]
}
The reason might be that there are separated APIs, Contact API and Profile API.

Issue processing incoming emails in mailgun

I want to process the json (recieved through post request from mailgun of incoming email).
I'm using codeigniter.
Following is a portion the json that I'm dealing with.
},
"log-level": "info",
"timestamp": 1475215276.814206,
"message": {
"headers": {
"to": "helpdesk#example.com",
"message-id": "CALv887xt-=_ijgb1iC0BQcOwJXguOWbiF7j+Licx6kqperh5Zg#mail.gmail.com",
"from": "User Test <user.test#gmail.com>",
"subject": "example email for testing"
},
"attachments": [],
"recipients": [
"53954680dacd5416eedb3f8639ece5f9#email.example.com"
],
I do not have any problem accessing the from value $this->input->post('from') and subject value $this->input->post('subject').
However I'm trying to access the to and recipients with the following code, but all I'm getting is null values.
$to = $this->input->post('to');
$message_header = $this->input->post('message');
$recipients = $message_header->recipients;
$email = $recipients[0];
$email_q = filter_var($email, FILTER_SANITIZE_EMAIL);
Any help would be great.
Got the to address in the following way.
In Codeigniter:
$this->input->post('recipient');
In PHP:
$_POST['recipient'];

DreamFactory problems sending email

Okay so I setup my own locally running copy of DreamFactory ... all this works on the hosted version ... but my problem when i try to send a test email using say this:
{
"to": [
{
"name": "Demo",
"email": "demo#acme.com"
}
],
"subject": "Testing SMTP Email Service",
"body_text": "I am sending a Test email from my DSP."
}
I get this response:
{
"error": [
{
"context": null,
"message": "Failed to send to the following addresses:Array\n(\n [0] => demo#acme.com\n)\n",
"code": 500
}
]
}
Seems to me it's trying to use all of that for the email address instead of the address itself and I can not figure out why.
Please try upgrading to the newest version of the DSP (v. 1.7.8)
I was able to use this json on my localhost and all was okay:
{
"to": [{
"name": "Demo",
"email": "demo#acme.com"
}],
"subject": "Testing SMTP Email Service",
"body_text": "I am sending a Test email from my DSP."
}
If it gives another issue after you upgrade, please let me know.
Thanks,
Mark

Categories