twitter login not working on my server - twitter

When I try to login from server
[http_code] => 401
[url] => https://api.twitter.com/oauth/request_token
[host] => https://api.twitter.com/1.1/
[timeout] => 30
[connecttimeout] => 30
[ssl_verifypeer] =>
[format] => json
[decode_json] => 1
[http_info] => Array
(.....
When I try to login from my Localhost its working fine
[http_code] => 200
[url] => https://api.twitter.com/oauth/request_token
[host] => https://api.twitter.com/1.1/
[timeout] => 30
[connecttimeout] => 30
[ssl_verifypeer] =>
[format] => json
[decode_json] => 1
[http_info] => Array
(.....
Can anyone help me. My twitter_consumer_token and twitter_consumer_secret are correct

I think your server time has not set properly

Related

Validate Twilio Notify deliveryCallbackUrl - What is the desired format for a nested request?

I'm working on a project that uses Twilio Notify for mass text notifications. I would like to track the status of individual messages, so I added a deliveryCallbackUrl to the notification resource.
$notification = $service->notifications->create([
"toBinding" => $binding,
"body" => $message_text,
"deliveryCallbackUrl" => "https://username:password#mysite/notification_delivery_callback.php"
]);
I can successfully receive the callback payload, but when I attempt to validate the request, it fails.
use Twilio\Rest\Client;
use Twilio\Security\RequestValidator;
$configs = get_configs();
$signature = $_SERVER["HTTP_X_TWILIO_SIGNATURE"];
$request_url = $_SERVER['SCRIPT_URI'];
$validator = new RequestValidator($configs['twilio_auth_token']);
$request = $_REQUEST;
// $is_valid always returns false
$is_valid = $validator->validate($signature, $request_url, $request);
The payload is nested and includes json.
Array(
[NotificationSid] => NTxxxxxxxxx
[ServiceSid] => ISxxxxxxxxx
[Count] => 4
[IsFinal] => true
[DeliveryState] => Array(
[3] => {"status":"SENT","type":"sms","identity":"xxxxxxxxx","sid":"SMxxxxxxxxx"}
[2] => {"status":"SENT","type":"sms","identity":"xxxxxxxxx","sid":"SMxxxxxxxxx"}
[1] => {"status":"SENT","type":"sms","identity":"xxxxxxxxx","sid":"SMxxxxxxxxx"}
[0] => {"status":"SENT","type":"sms","identity":"xxxxxxxxx","sid":"SMxxxxxxxxx"}
)
[AccountSid] => ACxxxxxxxxx
[SequenceId] => 0
)
It seems the DeliveryState array is the issue, as I am able to successfully validate non-nested requests for other webhooks. I've crawled through Twilio help docs, but so far, haven't found anything about how to validate nested requests. I've attempted to flatten the array and escape the json (one or the other, both at the same time), but no luck.
Array(
...
[DeliveryState] => Array(
[0] => "{\"status\":\"SENT\",\"type\":\"sms\",\"identity\":\"xxxxxxxxx\",\"sid\":\"SMxxxxxxxxx\"}"
[1] => "{\"status\":\"SENT\",\"type\":\"sms\",\"identity\":\"xxxxxxxxx\",\"sid\":\"SMxxxxxxxxx\"}"
[2] => "{\"status\":\"SENT\",\"type\":\"sms\",\"identity\":\"xxxxxxxxx\",\"sid\":\"SMxxxxxxxxx\"}"
[3] => "{\"status\":\"SENT\",\"type\":\"sms\",\"identity\":\"xxxxxxxxx\",\"sid\":\"SMxxxxxxxxx\"}"
)
...
)
Array(
...
[0] => "{\"status\":\"SENT\",\"type\":\"sms\",\"identity\":\"xxxxxxxxx\",\"sid\":\"SMxxxxxxxxx\"}"
[1] => "{\"status\":\"SENT\",\"type\":\"sms\",\"identity\":\"xxxxxxxxx\",\"sid\":\"SMxxxxxxxxx\"}"
[2] => "{\"status\":\"SENT\",\"type\":\"sms\",\"identity\":\"xxxxxxxxx\",\"sid\":\"SMxxxxxxxxx\"}"
[3] => "{\"status\":\"SENT\",\"type\":\"sms\",\"identity\":\"xxxxxxxxx\",\"sid\":\"SMxxxxxxxxx\"}"
...
)
Does anyone know what the desired format is to validate this properly?
Worked with Twilio Support to solve the issue.
There was a bug in the sdk: The PHP library didn't support multi-dimensional arrays in the RequestValidator (twilio/sdk has been fixed and updated to 6.42.1)
Format: The validator is looking for a specific format -- need to unnest the DeliveryState array and reformat the keys (order is also important)
Example format that passes validation
(
[NotificationSid] => NTxxx
[ServiceSid] => ISxxx
[Count] => 5
[IsFinal] => true
[DeliveryState[0]] => {"status":"SENT","type":"sms","identity":"xxxxxxxxxx","sid":"SMxxx"}
[DeliveryState[1]] => {"status":"SENT","type":"sms","identity":"xxxxxxxxxx","sid":"SMxxx"}
[DeliveryState[2]] => {"status":"SENT","type":"sms","identity":"xxxxxxxxxx","sid":"SMxxx"}
[DeliveryState[3]] => {"status":"SENT","type":"sms","identity":"xxxxxxxxxx","sid":"SMxxx"}
[DeliveryState[4]] => {"status":"SENT","type":"sms","identity":"xxxxxxxxxx","sid":"SMxxx"}
[AccountSid] => ACxxx
[SequenceId] => 0
)

original_transaction_id is not coming while validating Apple receipt after Successful IAP

I have Auto-renewable IAP plan in my App, which user has to purchase to listen full song. The issue has occurred moments after the user has made the in-app purchase and the app has been notified as to the successful transaction, then the appStoreReceipt in the app is validated.
I have base64 encoded string(that I can share in personal) and I am adding response after I verified the receipt, Also I have included master shared secret and app specific shared secret.
I also raised a bug on Apple feedback assistance, but they are not replying me since last week.
I hope anyone can help me out with this.
This is the response after validation of receipt:
<pre>ReceiptValidator\iTunes\ProductionResponse Object
(
[result_code:protected] => 0
[bundle_id:protected] => com.allaccess
[app_item_id:protected] => 1479910471
[original_purchase_date:protected] => Carbon\Carbon Object
(
[date] => 2020-06-04 17:28:14.000000
[timezone_type] => 1
[timezone] => +00:00
)
[request_date:protected] => Carbon\Carbon Object
(
[date] => 2020-08-25 15:40:51.000000
[timezone_type] => 1
[timezone] => +00:00
)
[receipt_creation_date:protected] => Carbon\Carbon Object
(
[date] => 2020-06-04 17:28:14.000000
[timezone_type] => 1
[timezone] => +00:00
)
[receipt:protected] => Array
(
[receipt_type] => Production
[adam_id] => 1479910471
[app_item_id] => 1479910471
[bundle_id] => com.allaccess
[application_version] => 1.0.1
[download_id] => 28071597429667
[version_external_identifier] => 836208084
[receipt_creation_date] => 2020-06-04 17:28:14 Etc/GMT
[receipt_creation_date_ms] => 1591291694000
[receipt_creation_date_pst] => 2020-06-04 10:28:14 America/Los_Angeles
[request_date] => 2020-08-25 15:40:50 Etc/GMT
[request_date_ms] => 1598370050555
[request_date_pst] => 2020-08-25 08:40:50 America/Los_Angeles
[original_purchase_date] => 2020-06-04 17:28:14 Etc/GMT
[original_purchase_date_ms] => 1591291694000
[original_purchase_date_pst] => 2020-06-04 10:28:14 America/Los_Angeles
[original_application_version] => 1.0.1
[in_app] => Array
(
)
)
[latest_receipt:protected] =>
[latest_receipt_info:protected] => Array
(
)
[purchases:protected] => Array
(
)
[pending_renewal_info:protected] => Array
(
)
[raw_data:protected] => Array
(
[receipt] => Array
(
[receipt_type] => Production
[adam_id] => 1479910471
[app_item_id] => 1479910471
[bundle_id] => com.allaccess
[application_version] => 1.0.1
[download_id] => 28071597429667
[version_external_identifier] => 836208084
[receipt_creation_date] => 2020-06-04 17:28:14 Etc/GMT
[receipt_creation_date_ms] => 1591291694000
[receipt_creation_date_pst] => 2020-06-04 10:28:14 America/Los_Angeles
[request_date] => 2020-08-25 15:40:50 Etc/GMT
[request_date_ms] => 1598370050555
[request_date_pst] => 2020-08-25 08:40:50 America/Los_Angeles
[original_purchase_date] => 2020-06-04 17:28:14 Etc/GMT
[original_purchase_date_ms] => 1591291694000
[original_purchase_date_pst] => 2020-06-04 10:28:14 America/Los_Angeles
[original_application_version] => 1.0.1
[in_app] => Array
(
)
)
[status] => 0
[environment] => Production
)
[is_retryable:protected] =>
)
Here, there is no original_transaction_id. I am facing this issue since last month.
Thank you

Twilio Browser Call Sends Wrong Call Sid in POST

I have setup browser calls and in my TwiML App , setup the Status CallBack url . Twilio posts the status in the format
array (
'ApiVersion' => '2010-04-01',
'Called' => NULL,
'CallStatus' => 'completed',
'Duration' => '1',
'From' => 'client:browser',
'CallDuration' => '13',
'Direction' => 'inbound',
'Timestamp' => 'Mon, 16 Apr 2018 19:35:26 +0000',
'AccountSid' => 'asdasdasdadasdasdasdasdasdasdas',
'CallbackSource' => 'call-progress-events',
'ApplicationSid' => 'rwerwerwerwewewewewwrwe',
'Caller' => 'client:browser',
'SequenceNumber' => '0',
'To' => NULL,
'CallSid' => 'CA9c6408108969fsf6f1c53396003d931',
)
I am trying to get the call to ,from and other details. I did was
$callsid = $_POST['CallSid'];
$call = $client->calls($callsid)->fetch();
But it failed everytime. When I checked my dashboard for the CallSod , it is different from what they sent in the webhook.
Is there something I am missing ?
Resolved it. I need to get the Child Call SID to get that information .
$call = $client->calls->read(
array("ParentCallSid" => $callsid )
);

Rails, RestClient pass binary font file

I'm trying to use restclient to do this CURL post
curl -v -i -X POST -H 'X-Api-Secret: ' -F font=#myraid.ttf APIURL
This is what I have so far
response = RestClient::Request.execute(
:method => :post,
:url => api_url,
:headers => {:content_type => 'multipart/form-data', :accept => 'application/json', :X_Api_Secret => "xxxxxxxxx"}
)
which works perfectly until I try to pass a file like this
response =RestClient::Request.execute(
:method => :post,
:url => api_url,
:headers => {:content_type => 'multipart/form-data', :accept => 'application/json', :X_Api_Secret => "xxxxxxxxxx"},
:upload => {
:file => File.new(params[:custom_font][:font].path, 'rb')
}
)
It then seems to ignore my headers and I get a 403 error, I've also tried a regular rest-client post request like
response = RestClient.post api_url, { :X_Api_Secret => "xxxxxx"}
But again it breaks when I try to introduce the data file.
Any help, pointers or advice would be greatly appreciated.
Ok after a couple of days of head banging, I ended up using unirest instead, after updating to the latest version it worked straight away.
response = Unirest.post api_key,
headers:{
"X-Api-Secret" => "xxxxx"
},
parameters:{
"data" => "ccc"
}

Inconsistent display of checkboxes on PDF form filled with PDFtk

I am filling PDF forms in my rails app with the pdf-forms (https://github.com/jkraemer/pdf-forms) gem, based on PDFtk. Text fields work as I would expect, but my checkbox fields do not. The boxes display well in Chrome, but in Preview and Mail the checkbox fields appear empty.
class FormsController < ApplicationController
require 'pdf_forms'
def acord25
#policy = Policy.find(params[:id])
pdftk = PdfForms.new('/usr/local/bin/pdftk')
# find out the field names that are present in form.pdf
pdftk.get_field_names 'lib/pdfs/acord25.pdf'
# take form.pdf, set the 'foo' field to 'bar' and save the document to myform.pdf
pdftk.fill_form '/lib/pdfs/acord25.pdf', "acord25.pdf",
"F[0].P1[0].Form_CompletionDate_A[0]" => #policy.dateIssued,
"F[0].P1[0].Producer_FullName_A[0]" => #policy.client.broker.name,
"F[0].P1[0].Producer_MailingAddress_LineOne_A[0]" => #policy.client.broker.company,
"F[0].P1[0].Producer_MailingAddress_LineTwo_A[0]" => #policy.client.broker.address,
"F[0].P1[0].Producer_ContactPerson_FullName_A[0]" => #policy.legalVesting,
"F[0].P1[0].Producer_ContactPerson_PhoneNumber_A[0]" => #policy.client.broker.phone,
"F[0].P1[0].Producer_FaxNumber_A[0]" => #policy.client.broker.fax,
"F[0].P1[0].Producer_ContactPerson_EmailAddress_A[0]" => #policy.client.broker.email,
"F[0].P1[0].NamedInsured_FullName_A[0]" => #policy.client.name,
"F[0].P1[0].NamedInsured_MailingAddress_LineOne_A[0]" => #policy.client.address.titlecase,
"F[0].P1[0].GeneralLiability_CoverageIndicator_A[0]" => 1,
"F[0].P1[0].GeneralLiability_OccurrenceIndicator_A[0]" => 1,
"F[0].P1[0].GeneralLiability_GeneralAggregate_LimitAppliesPerLocationIndicator_A[0]" => 1,
"F[0].P1[0].Policy_PolicyNumberIdentifier_A[0]" => #policy.policyNumber,
"F[0].P1[0].Policy_EffectiveDate_A[0]" => #policy.dateEffective,
"F[0].P1[0].PolicyExpirationGeneral[0]" => #policy.term.dayEnd,
"F[0].P1[0].Insurer_FullName_A[0]" => "Lexington Insurance Company",
"F[0].P1[0].Insurer_NAICCode_A[0]" => 19437,
"F[0].P1[0].Insurer_FullName_B[0]" => "Commerce & Industry Insurance Company",
"F[0].P1[0].Insurer_NAICCode_B[0]" => 19410,
"F[0].P1[0].Insurer_FullName_C[0]" => "Great American Insurance Company",
"F[0].P1[0].Insurer_NAICCode_C[0]" => 37532,
"F[0].P1[0].Insurer_FullName_D[0]" => "Admiral Insurance Company",
"F[0].P1[0].Insurer_NAICCode_D[0]" => 24856,
"F[0].P1[0].GeneralLiability_InsurerLetterCode_A[0]" => "A",
"F[0].P1[0].GeneralLiability_EachOccurrence_LimitAmount_A[0]" => 1000000,
"F[0].P1[0].GeneralLiability_FireDamageRentedPremises_EachOccurrenceLimitAmount_A[0]" => 50000,
"F[0].P1[0].GeneralLiability_MedicalExpense_EachPersonLimitAmount_A[0]" => "Excluded",
"F[0].P1[0].GeneralLiability_PersonalAndAdvertisingInjury_LimitAmount_A[0]" => 1000000,
"F[0].P1[0].GeneralLiability_GeneralAggregate_LimitAmount_A[0]" => 2000000,
"F[0].P1[0].GeneralLiability_ProductsAndCompletedOperations_AggregateLimitAmount_A[0]" => 2000000,
"F[0].P1[0].Vehicle_InsurerLetterCode_A[0]" => "A",
"F[0].P1[0].Vehicle_HiredAutosIndicator_A[0]" => 1,
"F[0].P1[0].Vehicle_NonOwnedAutosIndicator_A[0]" => 1,
"F[0].P1[0].Policy_PolicyNumberIdentifier_B[0]" => #policy.policyNumber,
"F[0].P1[0].Policy_EffectiveDate_B[0]" => #policy.dateEffective,
"F[0].P1[0].Policy_ExpirationDate_B[0]" => #policy.term.dayEnd,
"F[0].P1[0].Vehicle_CombinedSingleLimit_EachAccidentAmount_A[0]" => 1000000,
"F[0].P1[0].ExcessUmbrella_InsurerLetterCode_A[0]" => "B",
"F[0].P1[0].ExcessUmbrella_OccurrenceIndicator_A[0]" => 1,
"F[0].P1[0].ExcessUmbrella_DeductibleIndicator_A[0]" => 1,
"F[0].P1[0].ExcessUmbrella_Umbrella_DeductibleOrRetentionAmount_A[0]" => #policy.coverages.first.deductibleOcc,
"F[0].P1[0].Policy_PolicyNumberIdentifier_D[0]" => #policy.policyNumber,
"F[0].P1[0].Policy_EffectiveDate_D[0]" => #policy.dateEffective,
"F[0].P1[0].Policy_ExpirationDate_D[0]" => #policy.term.dayEnd,
"F[0].P1[0].ExcessUmbrella_Umbrella_EachOccurrenceAmount_A[0]" => 10000000,
"F[0].P1[0].ExcessUmbrella_Umbrella_AggregateAmount_A[0]" => 10000000
send_file("#{Rails.root}/acord25.pdf", filename: "#{#policy.client.name} - #{#policy.carrier.name} - #{#policy.policyNumber} (#{Time.now}).pdf", type: "application/vnd.ms-excel")
end
end
TL;DR: Checked boxes display in Chrome, but not in Preview or Mail.
I appreciate any help or leads on what the problem might be. Thank you!
Turns out the PDF form was corrupted. Had to recreate form, not a PDFTK issue.

Resources