我正在为CodeIgniter开发我的REST客户端库,我正在努力研究如何在PHP中发送PUT和DELETE参数.
在一些地方我见过人们使用这些选项:
$this->option(CURLOPT_PUT, TRUE);
$this->option(CURLOPT_POSTFIELDS, $params);
Run Code Online (Sandbox Code Playgroud)
令人讨厌的是,这似乎什么都不做.这是设置PUT参数的正确方法吗?
如果是这样,我该如何设置DELETE参数?
$ this-> option()是我库的一部分,它只是构建一个CURLOPT_XX常量数组,并在执行构建的cURL请求时将它们发送到curl_setopt_array().
我试图使用以下代码读取PUT和DELETE参数:
case 'put':
// Set up out PUT variables
parse_str(file_get_contents('php://input'), $this->_put_args);
break;
case 'delete':
// Set up out PUT variables
parse_str(file_get_contents('php://input'), $this->_delete_args);
break;
Run Code Online (Sandbox Code Playgroud)
这里有两个选项,我以错误的方式接近这个或者我的库中有一个错误.如果你能告诉我这是否理论上可行,我可以直接调试,直到我解决它.
我不想再浪费时间在一个根本错误的方法上.
我正在寻找基于CodeIgniter的CMS.你能说一下我能用的CMS吗?
我想学习如何使用CMS作为参考来构建CodeIgniter应用程序.
我正在尝试为我的application.rb添加两个额外的配置选项,以便我可以在控制器中读出它们.
# Extra
config.twitter.key = 'foo'
config.twitter.secret = 'bar'
Run Code Online (Sandbox Code Playgroud)
我试图使用三种建议的方法访问它们:
self.config.twitter.key # Should be extended through ApplicationController Base
config.twitter.key # Inherited but with different syntax
CONFIG['twitter']['key'] #some massive magical array that apparently exists somewhere
Run Code Online (Sandbox Code Playgroud)
当我通过"debug"方法传递它们时,它们都会给我不同的错误,例如:
debug self.config.twitter.key # undefined method `key' for nil:NilClass
Run Code Online (Sandbox Code Playgroud)
发生什么了?
我正在创建一个系统,需要确保计划中的"旅行"不要超过一圈.为此,我尝试验证start_date和end_date,以确保它们不在另一个行程的开始和结束日期之内.
class TripdateValidator < ActiveModel::EachValidator
def validate_each(object, attribute, value)
# Check value exists as end_date is optional
if value != nil
parsed_date = Date.parse(value)
# is the start date within the range of anything in the db
trips = Trip.where(['start_date >= ? AND end_date <= ? AND user_id = ?', parsed_date, parsed_date, object.user_id])
# overlapping other trips, aghhh
object.errors[attribute] << 'oh crap' if trips
end
end
end
Run Code Online (Sandbox Code Playgroud)
日期来自type ="date"字段,该字段由jQuery UI Datepicker提供,并包含格式2011-01-01.这是2011-01-30 00:00:00 UTC的轨道,我不完全理解.
如果我尝试对此值使用Date.parse(),则会给出错误:
TripsController中的TypeError #create
$ _ value需要是String(nil给出)
Rails.root: …
以下示例和教程,用于使用AWS Elastic Beanstalk启动和运行PHP应用程序,并在尝试推送时收到错误:
git aws.push
remote:
remote: error: Internal Error
remote:
To https://MYKEY:20120830T1133112489ce23684fb0061664e8de896cce922cf6d06981add734c00e356828847eb54@git.elasticbeanstalk.us-east-1.amazonaws.com/repos/4d7920466972737420256c6173746963204265616e7374616c6b204170706c69636174696f6e20456e7669726f6e6d656e6463/philsturgeon
! [remote rejected] HEAD -> master (hook declined)
error: failed to push some refs to 'https://MYKEY:20120830T1133112489ce23684fb0061664e8de896cce922cf6d06981add734c00e356828847eb54@git.elasticbeanstalk.us-east-1.amazonaws.com/repos/4d7920466972737420256c6173746963204265616e7374616c6b204170706c69636174696f6e20456e7669726f6e6d656e6463/philsturgeon'
Run Code Online (Sandbox Code Playgroud)
这是什么原因?谷歌似乎没有任何想法.我最初认为它是由于我的主机不匹配,因为第二次运行aws.config它不会要求主机,但在手动更改配置后.git/config仍然会给出相同的错误.
[aws "endpoint"]
us-east-1 = git.elasticbeanstalk.us-east-1.amazonaws.com
ap-northeast-1 = git.elasticbeanstalk.ap-northeast-1.amazonaws.com
eu-west-1 = git.elasticbeanstalk.eu-west-1.amazonaws.com
us-west-1 = git.elasticbeanstalk.us-west-1.amazonaws.com
us-west-2 = git.elasticbeanstalk.us-west-2.amazonaws.com
[alias "aws"]
push = !git aws.elasticbeanstalk.push $@
config = !git aws.elasticbeanstalk.config $@
[aws]
accesskey = MYKEY
secretkey = MYSECRET
region = us-east-1
[aws "elasticbeanstalk"]
host = git.elasticbeanstalk.us-east-1.amazonaws.com
application = My First …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Chef部署我的应用程序代码,该部署正在为一个节点工作而在另一个节点上失败.我无法确定为什么它适用于一个节点而不是另一个节点具有完全相同的配置,但我至少可以尝试在失败的节点上调试问题.
deploy_revision app_config['deploy_dir'] do
scm_provider Chef::Provider::Git
repo app_config['deploy_repo']
revision app_config['deploy_branch']
if secrets["deploy_key"]
git_ssh_wrapper "#{app_config['deploy_dir']}/git-ssh-wrapper" # For private Git repos
end
enable_submodules true
shallow_clone false
symlink_before_migrate({}) # Symlinks to add before running db migrations
purge_before_symlink [] # Directories to delete before adding symlinks
create_dirs_before_symlink [] # Directories to create before adding symlinks
# symlinks()
action :deploy
restart_command do
service "apache2" do action :restart; end
end
end
Run Code Online (Sandbox Code Playgroud)
这是我部署代码的方法.请注意,我已经尝试完全禁用符号链接,因为Chef总是阻塞它自己的默认值.即使这样我也得到错误:
================================================================================
Error executing action `deploy` on resource 'deploy_revision[/var/www]'
================================================================================
Chef::Exceptions::FileNotFound
------------------------------
Cannot symlink /var/www/shared/config/database.yml …Run Code Online (Sandbox Code Playgroud) 我正在尝试让ElasticSearch使用v1.4x中的Completion Suggesters为我的自动完成服务索引内容.我正在按照ElasticSearch的建议- 你完成我并使用Go Client olivere/elastic.
我的索引方法看起来有点像这样:
func IndexVehicle(client *elastic.Client, vehicle Vehicle) (bool, error) {
// See if it exists already
fetch, err := client.Get().
Index(vehicleIndex).
Type("vehicle").
Id(vehicle.Id).
Do()
if err != nil || fetch.Found {
return false, err
}
vehicleName := fmt.Sprintf("%s %s (%s) %s", vehicle.Make, vehicle.Model, vehicle.Model_year, vehicle.Primary_fuel)
suggest := elastic.NewSuggestField()
suggest.Input(vehicle.Make, vehicle.Model, vehicle.Primary_fuel, vehicle.Model_year).
Output(vehicleName).
Payload(vehicle)
// Go forth and save
put, err := client.Index().
Index(vehicleIndex).
Type("vehicle").
Id(vehicle.Id).
Debug(true).Pretty(true).
BodyJson(indexBody{Name: vehicleName, Suggest: suggest}). …Run Code Online (Sandbox Code Playgroud) 我正在运行一个我曾经使用过数十亿次的食谱,当我用Chef + knife旋转一个新的EC2实例时,我得到了这些错误.
[2013-01-30T23:44:48+00:00] INFO: Processing user[dan] action create (/var/chef/cache/cookbooks/users/providers/manage.rb line 65)
[2013-01-30T23:44:48+00:00] INFO: user[dan] created
[2013-01-30T23:44:48+00:00] INFO: Processing directory[/home/dan/.ssh] action create (/var/chef/cache/cookbooks/users/providers/manage.rb line 81)
[2013-01-30T23:44:48+00:00] INFO: directory[/home/dan/.ssh] created directory /home/dan/.ssh
[2013-01-30T23:44:48+00:00] INFO: directory[/home/dan/.ssh] owner changed to 2003
[2013-01-30T23:44:48+00:00] INFO: directory[/home/dan/.ssh] group changed to 2003
[2013-01-30T23:44:48+00:00] INFO: directory[/home/dan/.ssh] mode changed to 700
[2013-01-30T23:44:48+00:00] INFO: Processing template[/home/dan/.ssh/authorized_keys] action create (/var/chef/cache/cookbooks/users/providers/manage.rb line 88)
[2013-01-30T23:44:48+00:00] FATAL: Could not load Moneta back end "BasicFile"
================================================================================
Error executing action `create` on resource 'template[/home/dan/.ssh/authorized_keys]'
================================================================================
LoadError …Run Code Online (Sandbox Code Playgroud) 我正在使用OmniAuth + Devise允许用户使用附加到普通用户帐户的Facebook/Twitter/Gowalla/etc进行注册.现在,当用户使用其中任何一个或他们的帐户登录时,他们所有的社交网络都附加在身份验证表中.
我需要能够从任何这些提供商中提取内容,例如他们的推文或他们的Facebook Places检查等.我明白我需要使用不同的gem,插件,无论做什么,但得到我需要的配置使用这些宝石(并提出请求)让我很困惑.
我需要能够访问omniauth.rb中的提供程序配置项,因此我有API密钥和密钥等,然后我需要能够从oAuth的东西中获取令牌来发出请求.
像https://github.com/jrallison/authlogic_oauth这样的其他宝石似乎存储了oauth_token,oauth_secret和oauth_token,但是OmniAuth没有.
你可能会告诉我,我对Ruby,Rails和oAuth都是新手,所以这是一个非常具有挑战性的应用程序.非常需要帮助.
ruby-on-rails ruby-on-rails-plugins omniauth ruby-on-rails-3
我正在尝试使用OA提供的使用Zend Imap类的PHP示例代码进入带有OAuth的IMAP服务器,但我无法进行身份验证.Zend给了我错误:
Zend_Mail_Storage_Exception [ Error ]: cannot select INBOX, is this a valid transport?
Run Code Online (Sandbox Code Playgroud)
令人讨厌的是,这是一个相当混乱的错误消息,基本上是"无效的凭据".我怎么知道的?通过调试发送到IMAP套接字的实际命令,我看到:
string(44) "NO Invalid credentials ey9if1544983wid.142
"
Run Code Online (Sandbox Code Playgroud)
我尝试使用telnet和Ruby gmail_xoauth gem,这表明它不是代码问题,而是其他问题.
看看这一切的最基本水平,我得到这样的命令:
TAG1 AUTHENTICATE XOAUTH R0VUIGh0dHBzOi8vbWFpbC5nb29nbGUuY29tL21h......etc
Run Code Online (Sandbox Code Playgroud)
这是我得到的地方NO Invalid credentials:
TAG2 SELECT "INBOX"
Run Code Online (Sandbox Code Playgroud)
这会回来BAD Unknown command并踢我.
我一直试图寻找有同样问题的人,但我发现只有问题,没有答案.有一些类似StackOverflow的问题:
一篇帖子显示有人在Python中遇到完全相同的问题.
这篇文章显示有人试图尴尬并用OAuth 2做,没有成功的报告.
还有就是建议"无效凭证"的错误可以通过将要解决的Gmail谷歌集团线程https://accounts.google.com/DisplayUnlockCaptcha对于Gmail帐户和https://www.google.com/a/ [YOURDOMAIN.COM]/UnlockCaptcha如果您使用的是Google Apps,但后者只是说我的用户名和密码错误,当他们显然没有.使用此https://accounts.google.com/DisplayUnlockCaptcha工作正常 - 即使我的帐户是托管应用程序,而不是普通的旧GMail - 但是当我尝试使用由提供的PHP示例代码重新登录时,我仍然会遇到相同的错误谷歌.
我尝试过使用各种托管的Google App帐户和一个简单的GMail帐户.我已经尝试将IMAP服务器从imap.gmail.com切换到imap.googlemail.com,没有任何区别.
/**
* Make the IMAP connection and send the auth request
*/
$imap = new …Run Code Online (Sandbox Code Playgroud) Google的YouTube数据API的示例代码是一块垃圾.它太复杂了,并且与oauth重定向流有关,我无法使用它.试着用requestspip 去生,不要太过分.
我完全按照说明(据我所知),使用以下代码:
import json
import os
import sys
import urllib
import requests
payload_file = None
payload = None
print 'Loading Config'
# Get the directory path of this file. When using any relative file paths make
# sure they are relative to current_dir so that the script can be run from any CWD.
current_dir = os.path.dirname(os.path.abspath(__file__))
# Reads in the config.json file then parses it
config = json.loads(open(os.path.join(current_dir, '..', 'config.json')).read())
print 'Parsing Payload'
for i …Run Code Online (Sandbox Code Playgroud) chef-infra ×2
codeigniter ×2
php ×2
ruby ×2
curl ×1
deployment ×1
git ×1
gmail ×1
gmail-imap ×1
go ×1
http-headers ×1
imap ×1
omniauth ×1
python ×1
rest ×1
youtube ×1
youtube-api ×1