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
Related
I'm trying to register a webhook url on twitter app and I'm using this package twitteroauth.
But facing following error after executing Twitter endpoint to register webhook.
stdClass Object(
[errors] => Array
(
[0] => stdClass Object
(
[code] => 214
[message] => Webhook URL does not meet the requirements. Invalid CRC token or json response format.
)
)
)
I was tried to register webhook through code as follows:
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_POST['oauth_token'], $_POST['oauth_token_secret']); $webhookURL = "https://example.com/twitter/webhook"; $ucontent = $connection->post('account_activity/all/my_env_name/webhooks', array('url' => $webhookURL));
After reading some posts regarding this issue, I was tried the following code with url encoding:
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_POST['oauth_token'], $_POST['oauth_token_secret']); $webhookURL = "https://example.com/twitter/webhook"; $ucontent = $connection->post('account_activity/all/my_env_name/webhooks', array('url' => urlencode($webhookURL)));
I also read in some articles and regenerate the keys, tokens of my app and newly generated key, tokens in code.
But not get success to register webhook url.
Execute the Twitter endpoint to get the webhook related details, but its giving empty array
{ "environments": [ { "environment_name": "my-environment-name", "webhooks": [] } ] }
Expected output after successful webhook url registration in this array response:
{ "environments": [ { "environment_name": "my-environment-name", "webhooks": [ { "id" => webhook-id-here, "url" => https://example.com/twitter/webhook, "valid" => 1, "created_timestamp" => some-date-time } ] } ] }
Please help me for this issue.
I am building a simple SMS sending module with the RingCentral WebRTC client in PHP. I can successcully send messages and I get a valid JSON response object, and when I echo it out I can see the conversationId, but I cannot seem to echo it into a variable.
This is my API call:
$resp = $this->platform->post('/account/~/extension/~/sms',
array(
'from' => array ('phoneNumber' => $this->ringcentral_username),
'to' => array(array('phoneNumber' => $phone)),
'text' => $message
));
I can see:
"conversationId" : 1234567890,
in the response object, but $resp->conversationId is not found. How do I pull that out?
I found it:
$resp->json()->conversationId
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
Having difficulties authorizing php SoapClient with MS Dynamic Great Plains. I can connect through SoapUI. However, it only successfully connects on 3rd attempt. Also, the auth token progressively gets longer. See pastebin link below.
I made use of the following package (https://github.com/mlabrum/NTLMSoap) to setup a NTLM stream, but it doesn't seem to be sending a correct token. The token length is shorter than what is sent through SoapUI.
$wsdlUrl = 'http://example.org:48620/Metadata/Legacy/Full/DynamicsGP.wsdl';
$options = [
'ntlm_username' => 'Domain\username',
'ntlm_password' => 'password'
];
$soapClient = new \NTLMSoap\Client($wsdlUrl, $options);
$params = array(
criteria => array(
'ModifiedDate' => array(
'GreaterThan' => '2016-04-18',
'LessThan' => '2016-04-19'
)
),>
'context' => array(
'OrganizationKey' => array(
'type' => 'CompanyKey',
'Id' =
)
)
);
$soapClient->__setLocation('http://example.org:48620/DynamicsGPWebServices/DynamicsGPService.asmx');
$response = $soapClient->GetPurchaseOrderList(array($params));
I had to set use ___setLocation() because client was being forwarded to http://localmachine:48620/DynamicsGPWebServices/DynamicsGPService.asmx
I have been trying to get Charles Web Proxy to work to show the actual the request/response, buts its crapped out on me.
This is the SoapUI output. http://pastebin.com/7zg4E3qD
Just wondering if anyone knows why Amazon's AWS would be telling me "The X509 Certificate you provided does not exist in our records."
Here's the code I'm using...
$sqs = new AmazonSQS();
$queue_url = 'my_url';
$options = array(
'MaxNumberOfMessages' => 10,
);
$resp = $sqs->receive_message($queue_url, $options);
print_r($resp);
Here's the response I get...
[Type] => Sender
[Code] => InvalidClientTokenId
[Message] => The X509 Certificate you provided does not exist in our records.
[Detail] => CFSimpleXML Object
Here's the CFCredentials array I'm using inside config.inc.php...
'#default' => array(
'key' => 'my-key',
'secret' => 'my-secret',
'default_cache_config' => 'cache',
'certificate_authority' => FALSE
)
In order to use Amazon SQS, you have to specifically sign up for Amazon SQS ; it looks like you are not sign-up. You can do it by visiting this page and clicking the button labeled "Sign up for Amazon SQS".
The reason I was getting this error was because I am using MAMP PRO which doesn't have CURL installed with SSL. Only CURL.
So to get around this so I could test from my local machine was the below code. Note the "#" on the second line. I used this to suppress the warning that is given out by disable_ssl() method.
$s3 = new AmazonS3();
#$s3->disable_ssl();