how to know where http request 302 leads? - php

I'm working on Shopify API and trying to register uninstall webhook for my plugin which is registered successfully and i do get a response e.g.
stdClass Object
(
[webhook] => stdClass Object
(
[id] => 52102211
[address] => http://www.example.com/dev1/login?code=42db53dae6d706f095711b8365a941e8&hmac=6ca8a5fa6659ea9b976454d352c73024d98417b0e20665c08090c636d3c9662b&shop=my-shopify-shop.myshopify.comsignature=ed384b260216b100ea2090e0d3c26460×tamp=1438850605/delete_shop
[topic] => app/uninstalled
[created_at] => 2015-08-06T04:43:27-04:00
[updated_at] => 2015-08-06T04:43:27-04:00
[format] => json
[fields] => Array
(
)
[metafield_namespaces] => Array
(
)
)
)
When i delete my plugin it generates a 302 POST request.
I want to see that where does this request leads so that I'd be sure that it is coming straight to my controller action for handling this i.e. to example.com/delete_shop
I'm working in PHP CI and sending email in my code upon the call of this function. Here are the routes:
$route['default_controller'] = "home";
$route['product_edit/:any'] = "home/product_edit";
$route['delete_shop'] = "home/delete_shop";
$route['404_override'] = '';
Is there any problem with my routes because I never receive an email even after hours?
(email functionality is working properly in the application though)
EDIT :
here is the image for the request generated

A 302 is a temporaly redirect. You can follow the requests with tools as:
Firebug (https://getfirebug.com/downloads)
Browser console for developers in Chrome, Safari, Firefox, Internet Explorer, etc.
The tools above make it possible to log the requests. Detailed information provided, such as request headers, response headers, response body, etc.

Related

Shopify is giving error 400 [Bad Request] when using https://{shop}.myshopify.com/admin/oauth/access_token

I was developing a Shopify App. It was working fine till yesterday evening, but then I started getting the Bad Request [400] error, after the user allow access to the app for his shop.
Error is below
(https://SHOP-NAME.myshopify.com/admin/oauth/access_token) in /path/to/shopify/authentication/oauth.php on line 28
Array (
[method] => POST
[uri] => https://SHOP-NAME.myshopify.com/admin/oauth/access_token
[query] => Array ( )
[headers] => Array ( )
[payload] => Array (
[client_id] => {CLIENTID}
[client_secret] => {CLIENT_SECRET}
[code] => {CODE}
)
)
I'm doing a POST cURL Request with Content-Type:application/x-www-form-urlencode and all the request are validated to be coming from shopify.
If anyone want more information I can provide.
Thanks.
If this happening after the user authorizes the app, it could be an issue with the permanent token they have received. You could try grabbing the token that is generated and doing a POSTMAN request manually to query the API to verify the token works.
If it worked before and you didn't make any changes to the app, it could be a temporary API issue, even though I found that to be rare with my app.
The code parameter that is sent from Shopify can only be used a single time.
If you re-make the original request that sends the code parameter to your server, you should be able to make the call successfully.

Google Calendar Push Notification watch command in php

I am using the php watch commant:
$service = new Google_Service_Calendar($client);
$channel = new Google_Service_Calendar_Channel($client);
$channel->setId('20fdedbf0-a845-11e3-1515e2-0800200c9a6689111');
$channel->setType('web_hook');
$channel->setAddress('https://www.exampel.com/app/notification');
$watchEvent = $service->events->watch('primary', $channel);
This command works fine and I get the response:
Google_Service_Calendar_Channel Object ( [address] => [expiration] => 1401960485000 [id] => 20fdedbf0-a845-11e3-1515e2-0800200c9a6689111 [kind] => api#channel [params] => [payload] => [resourceId] => HZjSdbhwcd5KMKEA3ATA31LoR-w [resourceUri] => https://www.googleapis.com/calendar/v3/calendars/primary/events?key=AIzaSyBl_Y7Y4eQDve-0DjwzBEP7_qOLo-67ouY&alt=json [token] => [type] => [modelData:protected] => Array ( ) [processed:protected] => Array ( ) )
However; In my set up url I don't get any message when something changes in my calendar.
Am I missing something!?
I had a similar issue which was caused by authentication on my application.
Try sending a post request to https://www.exampel.com/app/notification and see if it is received. If not, double check your routing or authentication.
Also ensure that the endpoint is a valid https URL. Self-signed certificates are not allowed.
Source: https://developers.google.com/google-apps/calendar/v3/push
I have faced this issue today, so want to add some more details here.
Google only send the headers to your URL. so if you are waiting for getting some data (just like me) you won't get any (except some cases).
Check this Google Calendar API docs for Receiving Notifications
Understanding the notification message format
All notification messages include a set of HTTP headers that have X-Goog- prefixes. Some types of notifications can also include a message body.
Here are the headers I received in my webhook callback URL.
[Host] => mydomain.com
[X-Goog-Channel-ID] => 10ddfddt0-a995-10f4-1254e2-0000000a0a0609001
[X-Goog-Channel-Expiration] => Thu, 11 Jan 2018 10:04:04 GMT
[X-Goog-Resource-State] => exists
[X-Goog-Message-Number] => 2526579
[X-Goog-Resource-ID] => 9OG_a-ECJycPkpNR1ZrWSon5_i1
[X-Goog-Resource-URI] => https://www.googleapis.com/calendar/v3/calendars/primary/events?maxResults=250&alt=json
[Content-Length] => 0
[Connection] => keep-alive
[User-Agent] => APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)
[Accept-Encoding] => gzip,deflate,br
I also found some additional code sample here which you can use if you want to make the request to Google API without client library.
Hope this help someone.

WooCommerce RestFul API URL showing 404 Error

I have the Restful settings enabled on the settings page and I have create a user with access keys.
I am using the PHP library and im getting this reponse.
stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[code] => 404
[message] => cURL HTTP error 404
)
)
)
If i visit the url in the browser /wc-api/v1 I also get a 404 response. I have seen some mentions of changing Permalink structure but it doesn't say what too anywhere?
Any pointers? Greatly received :)
Ok so they settings I need were...
Post name http://www.dipdye.co.uk/sample-post/
and
Shop base with category http://www.dipdye.co.uk/shop/product-category/sample-product/
After further reading it seems any 'pretty' url will work, my main issue was it not updating my Web.config file (as Im on IIS) on Apache this would be the .htaccess file.
I can now see something when i visit the page in web browser.
Hope this help someone else too.

Instagram Requirements For Callback URL

Recently I had a problem on subscribing to a tag. I get this error:
Array ( [meta] => Array ( [error_type] => APISubscriptionError [code] => 400 [error_message] => Unable to reach callback URL "insert my url here". ) ) ""###
even though my url can be accessed globally.
In the documentation, it says that the callback url must support GET and POST methods. My
callback url passed that requirement but I am still getting the error.
Can somebody tell me what I am missing?

OpenID check_authentication not working

Merged with OpenID check_authentication not working.
I'm trying to write my own provider in PHP (JanRain libraries are confusing as all hell, and even phpMyID doesn't document exactly what is happening). I've got authentication working, but when the relying party tries to do check_authentication, it says my server denied it.
This is debugging information I captured during a check_authentication request.
$_GET:
Array
(
[mode] => profile
[username] => jrhodes
[domain] => roket-enterprises.com
)
$_POST:
Array
(
[openid_assoc_handle] => {HMAC-SHA1}{4abdf2f1}{olw8ag==}
[openid_identity] => http://www.roket-enterprises.com/openaccount/openid:jrhodes
[openid_mode] => check_authentication
[openid_response_nonce] => 2009-09-26T10:54:41ZLg0kfQ
[openid_return_to] => http://www.wasab.dk/morten/2007/11/openid/?janrain_nonce=2009-09-26T10%3A54%3A37Z9rZCkP&openid1_claimed_id=http%3A%2F%2Fwww.roket-enterprises.com%2Fopenaccount%2Fopenid%3Ajrhodes
[openid_sig] => Xl94j3IJtfSEQ4oKfova68I8edc=
[openid_signed] => assoc_handle,identity,mode,response_nonce,return_to,signed,sreg.email,sreg.fullname,sreg.nickname
[openid_sreg_email] => jrhodes#roket-enterprises.com
[openid_sreg_fullname] => James Rhodes
[openid_sreg_nickname] => jrhodes
)
Using Specific Mode Endpoint Handler...
Answering check_authentication
Headers:
Content-Type: text/plain;
openid.mode: id_res;
openid_mode: id_res;
sreg.fullname: James Rhodes;
sreg.nickname: jrhodes;
sreg.email: jrhodes#roket-enterprises.com;
is_valid: true;
The GET and POST data is the data that my script is receiving. Everything after "Headers:" are the headers that my script is returning. According to the specifications, I can't see anything wrong with this.
I've been asking on #openid for the last 4 hours and haven't got a response (note to self: post on StackOverflow, then ask IRC). Can anyone help?

Categories