I am using API of Xverify for email verifiation
Below is my API code:
require 'XverifyClientAPI.php';
$api_key = 'myapikey'; // Your API Key
$options = array();
$options['type'] = 'json'; // API response type
$options['domain'] = 'addeddomainname';// Reruired your domain name
$client = new XverifyClientAPI($api_key,$options);
$data = array();
$data['email'] = 'test#xverify.com';
$client->verify('email',$data);
echo '<pre>';
echo "valid: ", var_dump($client->is_valid()), "\n";
echo "status: ", $client->status(), "\n";
print_r($client->getReponseAsObject());// Convert the json response into object
Here I have use API key which is provided in my xverify account and domain name which is added in my xverify account
but still its give me error like below
valid: bool(false)
status: bad_request
stdClass Object
(
[syntax] => 1
[handle] => test
[domain] => xverify.com
[catch_all] => unknown
[address] => test#xverify.com
[error] => 0
[status] => bad_request
[responsecode] => 504
[message] => Reach the API Limit
[duration] => 0.013515949249268
)
I am not getting what is the problem with this ,can any body help me ?
Make sure you are using the correct url to call the api, in my case i had to the the domian name us.xverify.com to make it work, before i was using only xverify.com which always gave me the result same as yours(api limit reached), to check the correct api call log in to your xverify account and then click on setting and select email and scroll to the bottom of the page and check the correct url. If the id was created in the us i guess you have to use us.xverify.com
Related
I have subscribed my endpoint and now I need to pull the emailAddress from the object/array I cannot get the value 'fakeemail#
gmail.com' for the life of me
Aws\Sns\Message Object
(
data:Aws\Sns\Message:private => Array
(
Type => Notification
MessageId => hghkvvhhv32hg32vh23v32hjk32bjk
TopicArn => arn:aws:sns:us-west-232jh32bhj322j3hv23jhv23jhv2
Message => {"notificationType":"Bounce","bounce":{"bounceType":"Permanent","bounceSubType":"Suppressed","bouncedRecipients":,"timestamp":"2016-06-21T04:43:05.786Z","feedbackId":"wef-a5166c3e-fe-11e6-923e4-1115qbdde1aq2907d-000000","reportingMTA":"dns; amazonses.com"},"mail":{"timestamp":"2016-06-21T04:43:04.000Z","source":"www-data#myserver.com","sourceArn":"arn:aws:ses:us-west-2:0f2243234320627162:identity/myserver.com","sendingAccountId":"0243122452162","messageId":"0103714433d74e-e3bfd2dd3b3b7-49238-45a3f-953fa-c9a3eb3fd312c-03300000","destination":["fakeemail#
gmail.com"]}}
Timestamp => 2016-06-21T04:43:05.882Z
SignatureVersion => 1
Signature => vfvdfvsdffsvfadvfdvdfvdfdfsdvsdfdf
SigningCertURL => https://sns.us-west-2.amazonaws.com/SimpleNotificationService-vafvadfvadsvdsfdsvsvdsdfsdvsdsvd.pem
UnsubscribeURL => https://sns.us-west-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-west-2:02vsddfvddv43230vfvsvf67162:email_bounce:5fc6vsdfvd6af9-cfssdvdv197-4vfsdf0f-afb7-67fvdfs1b
)
)
I have changed my details above but this is what is given. I need to get the
fakeemail#gmail.com from array in the object but cant for the life of me
//from aws sdk
$message = Message::fromRawPostData();
I used
print_r($message['Message'], true);
to get the data above would be appreciated :)
Ok I figured it out. You want to take the
$message['Message']
and encode it to json to use as an object
$test = json_decode($message['Message']);
$returnsMyAnswer = print_r($test-> mail-> destination[0], true);
and then
echo $returnsMyAnswer;
and you get
fakeemail# gmail.com
I am using a PHP library (https://github.com/djchen/oauth2-fitbit) to retreive a users Fitbit data via Oauth2. I am getting the data correctly but I am not sure how to grab a specific item from the multidimensional array response.
I am using code below but doesnt work
$response = $provider->getResponse($request);
var_dump($response['encodedId'][0]);
Full PHP code
$provider = new djchen\OAuth2\Client\Provider\Fitbit([
'clientId' => 'xxx',
'clientSecret' => 'xxx',
'redirectUri' => 'http://xxx-env.us-east-1.elasticbeanstalk.com/a/fitbitapi'
]);
// start the session
session_start();
// If we don't have an authorization code then get one
if (!isset($_GET['code'])) {
// Fetch the authorization URL from the provider; this returns the
// urlAuthorize option and generates and applies any necessary parameters
// (e.g. state).
$authorizationUrl = $provider->getAuthorizationUrl();
// Get the state generated for you and store it to the session.
$_SESSION['oauth2state'] = $provider->getState();
// Redirect the user to the authorization URL.
header('Location: ' . $authorizationUrl);
exit;
// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
unset($_SESSION['oauth2state']);
exit('Invalid state');
} else {
try {
// Try to get an access token using the authorization code grant.
$accessToken = $provider->getAccessToken('authorization_code', [
'code' => $_GET['code']
]);
// We have an access token, which we may use in authenticated
// requests against the service provider's API.
echo $accessToken->getToken() . "\n";
echo $accessToken->getRefreshToken() . "\n";
echo $accessToken->getExpires() . "\n";
echo ($accessToken->hasExpired() ? 'expired' : 'not expired') . "\n";
// Using the access token, we may look up details about the
// resource owner.
$resourceOwner = $provider->getResourceOwner($accessToken);
var_export($resourceOwner->toArray());
// The provider provides a way to get an authenticated API request for
// the service, using the access token; it returns an object conforming
// to Psr\Http\Message\RequestInterface.
$request = $provider->getAuthenticatedRequest(
'GET',
'https://api.fitbit.com/1/user/-/profile.json',
$accessToken
);
// Make the authenticated API request and get the response.
$response = $provider->getResponse($request);
var_dump($response['encodedId'][0]);
Response data
eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NjAzNzgxOTYsInNjb3BlcyI6InJ3ZWkgcnBybyByaHIgcmxvYyByc2xlIHJzZXQgcmFjdCByc29jIiwic3ViIjoiNEg4NU5WIiwiYXVkIjoiMjI3UUNXIiwiaXNzIjoiRml0Yml0IiwidHlwIjoiYWNjZXNzX3Rva2VuIiwiaWF0IjoxNDYwMzc0NTk2fQ.NN9OOx--3YLvwai0hl0ZRJ4MNWXlaMwcEJ_xxxxxb2382a930144c3a76e69567dcbf0d9834c574919fff8c268b378e635735f1bbf 1460378196 not expired array ( 'encodedId' => '4545NV', 'displayName'
=> 'dan', )...
I am using the same PHP library for FitBit API integration. The response you have pasted with the question is the data that is coming because of the following part of your code:
// requests against the service provider's API.
echo $accessToken->getToken() . "\n";
echo $accessToken->getRefreshToken() . "\n";
echo $accessToken->getExpires() . "\n";
echo ($accessToken->hasExpired() ? 'expired' : 'not expired') . "\n";
// Using the access token, we may look up details about the
// resource owner.
$resourceOwner = $provider->getResourceOwner($accessToken);
var_export($resourceOwner->toArray());
When you try to get the user profile from FitBit, you make the below request :
$request = $provider->getAuthenticatedRequest(
'GET',
'https://api.fitbit.com/1/user/-/profile.json',
$accessToken
);
// Make the authenticated API request and get the response.
$response = $provider->getResponse($request);
The $response comes in the below format and you can see there that "encodeId" is not the direct key there. Below is the example of var_dump($response); -
Array(
[user] => Array
(
[age] => 27
[avatar] => https://static0.fitbit.com/images/profile/defaultProfile_100_male.gif
[avatar150] => https://static0.fitbit.com/images/profile/defaultProfile_150_male.gif
[averageDailySteps] => 3165
[corporate] =>
[dateOfBirth] => 1991-04-02
[displayName] => Avtar
[distanceUnit] => METRIC
[encodedId] => 478ZBH
[features] => Array
(
[exerciseGoal] => 1
)
[foodsLocale] => en_GB
[fullName] => Avtar Gaur
[gender] => MALE
[glucoseUnit] => METRIC
[height] => 181
[heightUnit] => METRIC
[locale] => en_IN
[memberSince] => 2016-01-17
[offsetFromUTCMillis] => 19800000
[startDayOfWeek] => MONDAY
[strideLengthRunning] => 94.2
[strideLengthRunningType] => default
[strideLengthWalking] => 75.1
[strideLengthWalkingType] => default
[timezone] => Asia/Colombo
[topBadges] => Array
(
[0] => Array
(
)
[1] => Array
(
)
[2] => Array
(
)
)
[waterUnit] => METRIC
[waterUnitName] => ml
[weight] => 80
[weightUnit] => METRIC
)
)
In order to access anything in there you need to access it in this manner -
$encodedId = $response['user']['encodedId];
I hope this was helpful to you. You can ask more questions related to fitbit API as I have got it all working, including the Fitbit Subscriver API and Notifications.
I am trying to send sms messages using Twilio API in Wordpress, but I don't understand what is curl -u. Now I want to send sms using twilio and wordpress via wp_remote_post.
See twilio send sms docs API (via JSON)
My code:
function sending_sms_via_twilio_api(){
$oauth_args = array(
"body" => array(
"Body" => "Hello World",
"To" => "0000000",
"From" => "5555555",
),
"my_Sid:my_token"
);
$response = wp_remote_post('https://api.twilio.com/2010-04-01/Accounts/AC28fcd041ffe3edb8029779894b7912d3/Messages.json', $oauth_args);
$result = json_decode( wp_remote_retrieve_body($response), true );
print_r($result);
}
Result is:
Array ( [code] => 20003 [detail] => Your AccountSid or AuthToken was
incorrect. [message] => Authentication Error - No credentials provided
[more_info] => [status] => 401 )
Any solutions?
That is a simple authentication problem. You should check your credentials again.
A GET call on https://{AccountSid}:{AuthToken}#api.twilio.com/2010-04-01/Accounts with wrong credentials give that problem.
Also the api response give this error page as advice for you:
https://www.twilio.com/docs/errors/20003
Hope it helps
My problem is quite strange (at least to me) as I have a request URL that works in the console but throws the Sorry, that page does not exist error in my php script, even though the connection is up and running.
So this
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_secret']);
$user = $connection->get('account/verify_credentials');
print_r($user);
works great, the $user data is printed out on the screen.
However, I am unable to check a friendship status as:
$x = $connection->get('https://api.twitter.com/1.1/friendships/show.json?source_id=707482092&target_id=755811768&target_screen_name=assetspersonifi');
As I get the error.
When I put this request into the Twitter API console, it gives back the json that I don't receive in my php code.
I'm using Abraham's twitteroauth library but this does not work either:
$follows_faelazo = $connection->get('friendships/exists', array('user_a' => 'blfarago', 'user_b' => 'faelazo'));
if(!$follows_faelazo){
echo 'You are NOT following #faelazo!';
$connection->post('friendships/create', array('screen_name' => 'faelazo'));
} else {
print_r($follows_faelazo);
}
stdClass Object ( [errors] => Array ( [0] => stdClass Object ( [message] => Sorry, that page does not exist [code] => 34 ) ) )
I read that friendships/exists API is no longer supported by the Twitter API and I should use friendships/show but how if it's not working as you see above?
To prove that everything else is working, I can follow others with
$connection->post('friendships/create', array('screen_name' => 'faelazo'));
Why?
I found a way. Here's the documentation
$following = $connection->get('friendships/show', array(
'source_screen_name' => $_SESSION['username'],
'target_screen_name' => $screen_name_to_follow,
));
An alternative would be
$following = $connection->get('friendships/lookup', array('screen_name' => $screen_name_to_follow));
Look it up in Twitter doc.
Currently having a few issues accessing the country from a given user on facebook. I have requested the user_location permission and my graph API call also requests location however I am only ever returned the city and an ID for the location - never an actual country.
My requests etc are below. I am using the standard PHP SDK docs
// graph api request for user data
$request = new FacebookRequest( $session, 'GET', '/me?fields=birthday,name,statuses,photos,location' );
$response = $request->execute();
// get response
$response = $response->getGraphObject();
$data_we_need = array();
$data_we_need['name'] = $response->getProperty('name');
$data_we_need['birthday'] = $response->getProperty('birthday');
$data_we_need['location'] = $response->getProperty('location');
$statuses = $response->getProperty('statuses');
$data_we_need['statuses'] = $statuses->asArray();
$photos = $response->getProperty('photos');
$data_we_need['photos'] = $photos->asArray();
I am returned an results like:
[name] => xxxxxx
[birthday] => 05/14/1990
[location] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => Facebook\GraphObject
[backingData:protected] => Array
(
[id] => 112087812151796
[name] => Gloucester, Gloucestershire
)
)
I need to be able to get country from the location data provided.
Any help would be massively appreciated.
As far as I know the location & hometown fields are user inputs (community pages), hence you won't get stable results using the facebook API. You might rather want to try detecting the country yourself with the IP.