In my config/environment/development.rb, i have
config.ip: 'http://localhost:3000'
In my config/environment/production.rb, i have
config.ip = 'http://52.74.70.227'
I want to use something like config.url = 'http://example.com'
So when someone recives an activation email link from me the link shows http://example.com/abc intead of http://52.74.70.227/abc
in config/environment/development.rb define
config.action_mailer.default_url_options = {host: "localhost:3000"}
in config/environment/production.rb define
config.action_mailer.default_url_options = {host: "example.com"}
for more info check here http://api.rubyonrails.org/classes/ActionMailer/Base.html
Related
Using AngleSharp v 0.9.9, I'm loading a page with OpenAsync which sets a bunch of cookies, something like:
var configuration = Configuration.Default.WithHttpClientRequester().WithCookies();
var currentContext = BrowsingContext.New(configuration);
// ....
var doc = context.OpenAsync(url, token);
This works fine and I can see the cookies have been set. For example, I can do this:
var cookieProvider = currentContext.Configuration.Services.OfType<ICookieProvider>().First() as MemoryCookieProvider;
And examine it in the debugger and see the cookies in there (for domain=.share.state.nm.us)
Then I need to submit a post:
var request = new DocumentRequest(postUrl);
request.Method = HttpMethod.Post;
request.Headers["Content-Type"] = "application/x-www-form-urlencoded";
request.Headers["User-Agent"] = userAgent;
//...
Which eventually gets submitted:
var download = loader.DownloadAsync(request);
And I can see (using Fiddler) that it's submitting the cookies from the cookieProvider.
However, I need to add a cookie (and possible change the value in another) and no matter what I try, it doesn't seem to include it. For example, I do this:
cookieProvider.Container.Add(new System.Net.Cookie()
{
Domain = ".share.state.nm.us",
Name = "psback",
Value = "somevalue",
Path = "/"
});
And again I can examine the cookieProvider in the debugger and see the cookie I set. But when I actually submit the request and look in fiddler, the new cookie isn't included.
This seems like it should be really simple, what is the correct way to set a new cookie and have it included in subsequent requests?
I think there are two potential ways to solve this.
either use document.Cookie for setting a new cookie (would require an active document that already is at the desired domain) or
Use a Filter for getting / manipulating the request before its send. This let's you really just change the used cookie container before actually submitting.
The Filter is set in the DefaultLoader configuration. See https://github.com/AngleSharp/AngleSharp/blob/master/src/AngleSharp/ConfigurationExtensions.cs#L152.
I've been using Instagram's undocumented API https://www.instagram.com/<user>/?__a=1 to get a public user feed on a website. Since a while now, this is not working anymore, probably because Facebook removed it. Is there an other way to get the data of an instagram account in a easy way?
I built a small server which does that transformation. You'll receive the instagram data as before with ?__a=1 (as JSON ) - have fun 😊
https://www.instapi.io/u/<username>
https://www.instapi.io/u/appwithus
EDIT 12/2020: Unfortunately the service is no longer available
Edit 15/03 NOT WORKING ANYMORE Seems like instagram changed again their API, now it gives a CORS error.
As of 2 february 2021, I have found a solution
Instead of using https://www.instagram.com/username/?__a=1 which it asks for a login.
Justing adding a /channel seems to make it work, like so:
https://www.instagram.com/username/channel/?__a=1
There is a JSON data in https://www.instagram.com/<user>/.
You can use regexp to find what you need.
Sample
// This regexp gets widest possible dict around "profile_pic_url"
// but inside tag <script type="text/javascript">...</script>
let r = new RegExp('<script type="text\/javascript">' +
'([^{]+?({.*profile_pic_url.*})[^}]+?)' +
'<\/script>');
let source = document.documentElement.outerHTML;
let jsonStr = source.match(r)[2];
let data = JSON.parse(jsonStr);
console.log('data', data);
let oldVariantOfData = data['entry_data']['ProfilePage'][0];
console.log('oldVariantOfData', oldVariantOfData);
The same response is attached in the html response of the profile url, I perform this temporal solution (when I can't use the API) in python:
url_recent_media = 'https://www.instagram.com/%s/' % instagram_id
response = urllib2.urlopen(url_recent_media)
insta_html = response.read()
insta_html_split = insta_html.split('"ProfilePage":[')
if len(insta_html_split) > 1:
insta_html_split_2 = insta_html_split[1].split(']},"gatekeepers"')
if len(insta_html_split_2) > 1:
json_dict = json.loads(insta_html_split_2[0])
I hope this help you.
you can try without using instagram API.
import json, urllib2
img_dicts = []
url = 'https://www.instagram.com/{}/'.format(instagram_username)
try:
r = urllib2.urlopen(url, timeout=10.0)
instagram_html = r.read()
instagram_html_data = instagram_html.split('"ProfilePage":[')
if len(instagram_html_data) > 1:
instagram_html_final_data = instagram_html_data[1].split(']},"gatekeepers"')
if len(instagram_html_final_data) > 1:
json_dict = json.loads(instagram_html_final_data[0])
media = json_dict['graphql']['user']['edge_owner_to_timeline_media']['edges']
for obj in media:
img_dicts.append({
'id': obj['node']['id'],
'caption': obj['node']['edge_media_to_caption']['edges'][0]['node']['text'],
'imgurl_standard': obj['node']['display_url'],
'imgurl_lower': obj['node']['thumbnail_resources'][4]['src'],
'imgurl_thumb': obj['node']['thumbnail_resources'][3]['src']
})
img_dicts will give you images in different quality and caption of instagram post.
hi i have installed opencart extension tell a friend everything is good but email is not sending rest all emails when customer register and purchased are sending tell me the reason
here is the extension link also
http://www.opencart.com/index.php?route=extension/extension/info&extension_id=4348&filter_search=tell%20a%20friend
If some one has used this one please tell me
some time Opencart not work with emails on models. you need to put your logic in controller to fix this issue.
here is the solution:
get all value in your Opencart controller function and put Email logic init something like this.
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->request->post['email']);
$mail->setSender($this->request->post['name']);
$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8'));
$mail->setText(strip_tags(html_entity_decode($this->request->post['enquiry'], ENT_QUOTES, 'UTF-8')));
$mail->send();
In Bootstrap.php I have some custom routes using Zend_Controller_Router_Route_Regex.
Everything works fine except when user type in address bar a wrong link.
Ex :
http://mysite/en/1-some-article.html => This is a valid link that matches a ROUTE in Bootstrap.
But when user make a typo mistake like:
http://mysite/en/1-some-article.**html'** or http://mysite/en/1-some-article.**hhtml** , they are not match any ROUTE in Bootstrap, then Zend Framework throws an exception like : No route matched the request
Is there anyway to handle it, like redirecting to a custom page for "No matched routes"?
Any help will be appreciated. Thanks for advance!
Configuration (from comment below)
[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
phpSettings.date.timezone = "Europe/London"
;includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = ""
;resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules = ""
autoloaderNamespaces.Fxml = "Mycms_"
autoloaderNamespaces.Fxml = "Fxml_"
To make use of the ErrorController, you need to set the front controller throwExceptions attribute to false. Put this in your [production] configuration section
resources.frontController.params.throwExceptions = 0
See http://framework.zend.com/manual/1.12/en/zend.controller.exceptions.html and http://framework.zend.com/manual/1.12/en/zend.controller.plugins.html#zend.controller.plugins.standard.errorhandler.fourohfour.
I mentioned this in the comments above but you seem to have missed it (you have displayExceptions set to false but not throwExceptions).
I am trying to access dropbox account info using oauth2 library.
I have got hold of access token from dropbox. Then what I am doing is:
parameters = {
'oauth_consumer_key' : DropboxConstants.app_key, #my app key
'oauth_token' : access_token_g,#token that i got [<key>,<secret>]
'oauth_signature_method': oauth.SignatureMethod_HMAC_SHA1.name,
'oauth_timestamp' : oauth.generate_timestamp(),
'oauth_nonce' : oauth.generate_nonce(),
'oauth_version' : DropboxConstants.api_version,
'oauth_signature' : ''
}
#prepare signature
oauth_request= oauth.Request(method="GET",url=DropboxConstants.account_info_url,parameters=parameters)
signature_method_m = oauth.SignatureMethod_HMAC_SHA1()
signature = signature_method_m.signing_base(consumer=consumer,request=oauth_request,token=access_token_g)
parameters['oauth_signature'] = signature[1]
#prepare url for accessing account info
url = "%s?oauth_token=%s&oauth_consumer_key=%s&oauth_signature_method=%s&oauth_timestamp=%s&oauth_nonce=%s&oauth_version=%s&oauth_signature=%s"%\
(DropboxConstants.account_info_url,access_token['oauth_token'],parameters['oauth_consumer_key'],parameters['oauth_signature_method'],parameters['oauth_timestamp'],parameters['oauth_nonce'],parameters['oauth_version'], parameters['oauth_signature'])
return HttpResponseRedirect(url)
now the signature that is getting generated:
GET&https%3A%2F%2Fapi.dropbox.com%2F0%2Faccount%2Finfo&oauth_consumer_key%3Dedw6k7d78hu8q8v%26oauth_nonce%3D39519001%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1314679561%26oauth_token%3Doauth_token_secret%253Dun58fgoc14n9jlv%2526oauth_token%253D2ew2dafg0r40uwq%26oauth_version%3D1.0
error I get is:
{"error": "Invalid signature. Expected signature base string: GET&https%3A%2F%2Fapi.dropbox.com%2F0%2Faccount%2Finfo&https%253A%252F%252Fapi.dropbox.com%252F0%252Faccount%252Finfo%3D%26oauth_consumer_key%3Dedw6k7d78hu8q8v%26oauth_consumer_key%253Dedw6k7d78hu8q8v%2526oauth_nonce%253D39519001%2526oauth_signature_method%253DHMAC-SHA1%2526oauth_timestamp%253D1314679561%2526oauth_token%253Doauth_token_secret%25253Dun58fgoc14n9jlv%252526oauth_token%25253D2ew2dafg0r40uwq%2526oauth_version%253D1.0%3D%26oauth_nonce%3D39519001%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1314679561%26oauth_token%3D2ew2dafg0r40uwq%26oauth_version%3D1.0"}
firstly please use urlencode to escape chars correctly:
from urllib import urlencode
...
parameters['oauth_token'] = access_token_g['oauth_token']
url = "?".join(DropboxConstants.account_info_url, urlencode(parameters))
see if this helps, if not i'll look into the signiature base
Actually i have solved this problem with a bit change in code as:
access_token_g =
oauth.Token(key=access_token['oauth_token'],secret=access_token['oauth_token_secret'])
#prepare signature
oauth_request = oauth.Request(method="GET",url=account_info_url,parameters=parameters)
signature_method_m = oauth.SignatureMethod_HMAC_SHA1()
oauth_request.sign_request(signature_method=signature_method_m,consumer=consumer,token=access_token_g)
resp, content = client.request(oauth_request.to_url())
It gives me correct content..