how to create uninstall webhook in shopify using laravel wrapper? - laravel-5.3

i am trying to create webhook using the api call inlaravel but it gives me the error "The requested URL returned error: 406 Not Acceptable".
my code is as bellow.
$webhookData = [
'webhook' => [
'topic' => 'app/uninstalled',
'address' => url('/uninstall'),
'fields' => 'name',
'format' => 'json'
]
];
$uninstall = $sh->call(['URL' => 'https://' . $shop . '/admin/webhooks.json', 'METHOD' => 'POST', 'DATA' => $webhookData]);

There are certain things you need to take care of while creating the Shopify webhooks.
The address field should be a globally accessible URL (ex: https://example.com/webhook/uninstall.php)
You can not give localhost links for creating webhooks.
I think the address field is not passed with a valid URL in your post request.

Related

After Move http to https of wordpress thrid party API's not working

I have implemented the sigle signon in worpress with Java with Aws cognito.
it is working fine with http but after moving http to https. API's are not working and throwing the error below:
WP_Error Object
(
[errors] => Array
(
[http_request_failed] => Array
(
[0] => cURL error 35: error:1408F10B:SSL routines:ssl3_get_record:wrong version number
)
)
[error_data] => Array
(
)
)
I have consumed the get and Post API like below:
$bodyData = array(
'username' => $_POST['username'],
'password' => $_POST['password']
);
$response = wp_remote_post('https://example.com:8083/digitalIdentityProvider/login',
array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '2.0',
'sslverify' => true,
'blocking' => true,
'headers' => array('Content-Type'=> 'application/json'),
'body' => json_encode($bodyData) ,
'cookies' => array()
));
Could you please someone guide or suggest ?
Thanks.
After playing with wordpress code and AWS, I found the issue with Aws ELB and Load Balancer .
SSL Certificate has applied to LB and Third party API and wordpress were hosted on AWS EC2 and for EC2 there was not SSL certificate and I was trying to access API with
HTTPS:
https://example.com:8083/digitalIdentityProvider/login hence request was not verifying over there hence I was not receiving any response from API.
I have changed API call
from https://example.com:8083/digitalIdentityProvider/login
to http://example.com:8083/digitalIdentityProvider/login
after change it https to http. it working fine.

How to put an external link + the parameter

Currently, I would like to have redirected CV links to my AWS S3 bucket. I use Sonata Admin.
With the URL I am redirected on
->add('cvName', 'url', [
'url' => "https://s3.eu-west-3.amazonaws.com/*****/",
'attributes' => ['target' => '_blank']
])
Without I am redirect on the CV name.
->add('cvName', 'url', [
'attributes' => ['target' => '_blank']
])
I would like that when you click on the link, be redirected to the address "https://s3.eu-west-3.amazonaws.com/*****/ + CVNAME"
Thank you very much for your answer.
Try str_replace:
url = str_replace('*****', CVNAME, "https://s3.eu-west-3.amazonaws.com/*****/")

Fake URL Shortener

I want to redirect www.myhost.com/g/:id to www.myhost.com/jobs/view/:id. Currently the following code does that fine:
$routes->connect(
'/g/:id',
['controller' => 'Jobs', 'action' => 'view'],
['pass' => ['id'], 'status' => 301, 'persist' => ['id']]
);
However, in the addressbar it still shows www.myhost.com/g/:id. I'd like it to show the full URL (www.myhost.com/jobs/view/:id), not the 'shortened' URL.
How would I adjust the code to do the above?
Router::connect is a way of connecting one route to another, without a full redirect.
If you're wanting redirect a user and have that exposed to them, you can use Router::redirect(). It automatically will set the 301 status.
$routes->redirect(
'/g/:id',
['controller' => 'Jobs', 'action' => 'view'],
['pass' => ['id'], 'persist' => true]
);

Update User Meta with spaces using REST API - WordPress

I'm trying to update the user meta with spaces registered on my website. I am using register_meta hook to register user meta. And for updating users using WordPress REST API I use wp_remote_post but the problem is when I tried to update a user meta with spaces it will add as array in response then it will add as new user meta.
For example the value of user meta is - community test
Sample Response:
[meta] => Array
(
[agent_community] => Array
(
[0] => community
[1] => test
)
)
Sample Code for registering user meta.
register_meta('user', 'agent_community', array(
"type" => "string",
"show_in_rest" => true
));
Update using wp_remote_post
$update_data = array('email'=> 'test#mail.com', 'meta[agent_community]' => 'community test');
$args = array(
'headers' => array(
'Authorization' => 'Basic ' . base64_encode( 'username:password' ),
),
'body' => array_filter($update_data));
$update_url = 'https://test-url.com/wp-json/wp/v2/users/17';
$response = wp_remote_post( $update_url, $args);
Database:
Is there a way that can merge the array on user meta?
implode() might help you. And you can change spaces with HTML entities. Or use function like urledncode() / urlendecode() or something like this.

Edit mail.inc to enable SMTP server for sending mail

i want to place the following codes into include/mail.inc of Drupal7 so that i can send mail from SourceForge's project web space. Don't ask me to install SMTP Authentication Support, and i don't have access to php.ini , I wonder where should these codes be placed? Thanks in advance!
include('Mail.php');
$recipients = array( 'someone#example.com' ); # Can be one or more emails
$headers = array (
'From' => 'someone#example.com',
'To' => join(', ', $recipients),
'Subject' => 'Testing email from project web',
);
$body = "This was sent via php from project web!\n";
$mail_object =& Mail::factory('smtp',
array(
'host' => 'prwebmail',
'auth' => true,
'username' => 'YOUR_PROJECT_NAME',
'password' => 'PASSWORD', # As set on your project's config page
#'debug' => true, # uncomment to enable debugging
));
$mail_object->send($recipients, $headers, $body);
if this code could success send email without drupal7 (you must make sure it)
then you could do it in three ways:
write a drupal 7 module ,copy mail.php into *.module, and make the rest code as a function,that's the way as the handbook of drupal.
just copy all of the code to you theme/page.tpl.php , and run it directly , a little dirty
hack drupal core , include/mail.inc , just change function drupal_mail_send

Resources