I meet a very strange problem,I used sfPHPCaptchaPlugin to make captha to my form in sf1.4 project I worked on,all configuration and installation of plugin is correct but the captcha verification won't let me save data of form in database and tell me that the text is wrong but I'm sure I entered the same text showing in image of captcha and here is the line who get me the error :
'captcha' => new sfValidatorPHPCaptcha(array(), array('invalid' => 'The following code is invalid.')),
Someone had the same errore before please?
sfPHPCaptchaPlugin is not stable for symfony 1.4 as it said in the plugin information Here.
You can use sfCaptchaGDPlugin its a very good one, folow the intalation guide in README, and use this widget:
$this->widgetSchema['captcha'] = new sfWidgetCaptchaGD();
$this->validatorSchema['captcha'] = new sfCaptchaGDValidator(array('length' => 4));
Related
I'm converting URL syntax from 3.4 to 4.2 syntax (CMIS 1.0)
I'm trying to upload a new version of a document to the PWC via a PUT for a document.
Previous 3.X syntax to upload to the PWC was as follows:
/alfresco/service/cmis/pwc/i/{id}?checkinComment={checkinComment?}&major={major?}&checkin={checkin?}
In 4.2 I am using this URL:
/alfresco/api/-default-/public/cmis/versions/1.0/atom/content?id=2e9c6773-4b02-41e0-b8e5-ce04a48c44f6?checkinComment=hgfhfgh&checkin=true&major=true
Here 2e9c6773-4b02-41e0-b8e5-ce04a48c44f6 == ID of the PWC.
I'm getting the error:
The remote server returned an error: (404) Not Found.
What's wrong with this?
When I step through cmislib's checkIn unit test against a preview build of 4.2 Enterprise using the new service URLs, I see that the PUT that does the checkin is hitting this URL:
u'http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.0/atom/entry?id=71be4c86-1dcb-49a8-8373-d1c5ea4405b7%3Bpwc'
So try changing "content" to "entry" and also double-check that you have the ID of the PWC. Note that mine actually has "pwc" on the end whereas yours does not.
I am trying to use Gdata package of Zend-2 framework to access Youtube API.
I have a successfully working version with Zend 1.9 version. I am trying to port them to Zend 2 framework version.
The folder structure is
C:\wamp\www\plugins\youtube\
C:\wamp\www\plugins\youtube\Zend\ (all default folders that comes with ZF2)
C:\wamp\www\plugins\youtube\Zend\ZendGData (downloaded separately from Zend Packages page)
I have added the path C:\wamp\www\plugins\youtube\ to the include_path by using set_include_path() function and have verified the same.
I am using the below code to create the YouTube object.
$yt = new ZendGData\YouTube();
I am getting the below error.
Class 'ZendGData\YouTube' not found
I am not how to use the auto-loading feature of ZF2. I tried to include the Loader/StandardAutoloader.php file. But still the same.
If I include the Zend\ZendGData\YouTube.php file I get the notice that the ZendGData\Media is not found.
Please let me know if I am missing something silly.
EDIT:
Some more information on what I have done now.
Based on search from Stackoverflow site, I did the below changes.
use Zend\Loader\StandardAutoloader;
use ZendGdata\YouTube;
require_once 'C:\wamp\www\plugins\youtube\Zend\Loader\StandardAutoloader.php';
$loader = new StandardAutoloader(array('autoregister_zf' => true));
$loader->register();
$yt = new Zend\ZendGData\YouTube();
Now I get the below error.
Class 'ZendGData\Media' not found
After a lot of trial and error with the AutoLoader, the below code worked for me. If someone is having the same issue, here is the solution.
require_once 'C:\wamp\www\youtube\Zend\Loader\StandardAutoloader.php';
$loader = new StandardAutoloader(array(
'autoregister_zf' => true,
'namespaces' => array(
'ZendGData' => 'C:\wamp\www\youtube\Zend\ZendGdata\')
)
);
$loader->register();
$yt = new ZendGData\YouTube();
Source: https://github.com/abraham/twitteroauth/pull/137
In the above-mentioned link, a Github user, Robhaswell, made an adjustment to Abraham's TwitterOAuth code and added an upload function for uploading images. This is a great addition to the framework, however, there was no proper documentation or example attached to the new code, so I'm having a bit of trouble using the function:
$image = 'weather.jpg';
$response = $tweet->upload('statuses/update_with_media', array(
'status' => 'This is a test',
'media[]' => "#{$image};type=image/jpeg;filename={$image}")
);
Whereas weather.jpg is in the same folder as the file with the code above.
Side note: The code will be executed through cron and upload an image that is always already present on the server, to twitter. Just to clarify that users won't have to be able to upload their images first and then submit them to Twitter via this script.
Can anyone point me in the right direction?
Edit: I'm aware this functionality is not part of the original build and I have updated the twitteroauth and OAuth code in accordance to Robhaswell's adjustment.
Since this question is still relevant, but the answer is now outdated I'll go ahead and update this question with a more up-to-date answer.
statuses/update_with_media has been deprecated by twitter. https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update_with_media.html
Here is my working code that uploads and tweets a status with a picture.
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token, $access_token_secret);
$content = $twitter->get("account/verify_credentials");
$tweet = "My tweet";
$imageMedia = $twitter->upload('media/upload', array('media' => '/path/to/image/image_name.png'));
$parameters = array(
"status" => $tweet,
"media_ids" => $imageMedia->media_id_string);
$statuses = $twitter->post("statuses/update", $parameters);
I just thought I would post this here since I stumbled across this question while looking for an answer for it.
Since I've been struggling with this, I thought answering this question might help some other people. This uses abraham's twitteroauth with the added image upload functionality (code can be found here)
You should check if your image-path is correct. It has to point to a file on your server (relative).
Also, make sure the host is correct in the twitteroauth file (see upload function, where it briefly changes the host url, this isn't necessary anymore). You should now use
https://api.twitter.com/1.1/
instead of
https://upload.twitter.com/1/
Keeping these two things in mind following code should work (it does for me);
$this->api = new TwitterOAuth($consumerKey, $consumerSecret,$token, $token_secret);
$attachment = "./images/img.jpg";
$image = "#{$attachment};type=image/jpeg";
$status = "Text";
$result = $this->api->upload('statuses/update_with_media',array('status'=>$message,'media[]'=>$image));
If anyone has managed to get locally uploading images I'd be mightily appreciative of some help.
I've downloaded the latest version of nicEdit along with the nicUpload plug in (from nicedit.com - Version 0.9 r24 released June 7th, 2012).
I've also downloaded nicUpload.php from http://svn.nicedit.com//trunk/nicUpload/php/nicUpload.php
NicUpload.php - I've set NICUPLOAD_PATH and NICUPLOAD_URI both to 'images' which is the subfolder of where nicupload.php and nicEdit.js are located.
NicEdit.js - I've added the following to line 271:-
uploadURI : 'nicUpload.php?id=123',
I've given it an ID otherwise it was failing with an invalid ID code. But the ?id=123 isn't meant to be there. I've also set the iconsPath accordingly.
Line 1370 I've switched this:-
nicURI : 'http://api.imgur.com/2/upload.json',
for this:-
nicURI : 'http://www.mydomain.com/nicedit/nicUpload.php',
But I'm still getting "Failed to upload image". I've searched and searched and searched for answers to this and I'm getting close to having spent two days tinkering with it.
With a few debugging displays I can see that it's failing on line 46 of nicUpload.php where it says:-
$file = $_FILES['nicImage'];
$image = $file['tmp_name'];
$max_upload_size = ini_max_upload_size();
if(!$file) {...
That last IF is true and that's where it exits with the error.
Appreciate anyone being able to help.
The nicUpload.php script file laying around sucks and I don't even understand how it could work.
NicEditor uses imgur as the default image upload service. The source code follows the API format described here: http://api.imgur.com/resources_anon#upload
My suggestion would be to implement the API request and response defined there.
I did not use the niceedit upload function to do what you want. I managed to add a button to the link and img dropdown menu. The button opens a file manager window where you also can upload. I managed to put then de url of the image or document into the nicedit drop down img or url window. That is how I solved the problem.
I am trying to save a simple template to pdf using the rendering plugin, but I cannot get it to work no matter what I try. All I need is for it to save a file within the file system on the server and redirect to a different page.
At the minute the pdf template does not need any parameters as it just prints hello world. Once I get this working I will attempt to add some data.
I am getting errors saying I need to specify a controller if no '/' is appended. But I have tried adding this to no avail. Plus I don't understand which controller it needs as I have tried specifying the controller this action is declared.
Can someone please have a look at this and tell me what I'm doing wrong?
RenderingService pdfRenderingService
def displayPDFSummary = {
ByteArrayOutputStream bytes = pdfRenderingService.render(template: "_pdfTemplate", controller:"RSSCustomerOrder", model: [origSessionId:params.origSessionId])
def fos= new FileOutputStream('NewTestFile.pdf')
fos.write(bytes)
fos.close()
render(template: "_pdfTemplate", params: [origSessionId:params.origSessionId])
}
I am getting the following error messages in the console:
groovy.lang.MissingMethodException: No signature of method: java.io.FileOutputStream.write() is applicable for argument types: (java.io.ByteArrayOutputStream)
(Then prints contents of template...)
Possible solutions: write([B), write(int), write([B), write(int), wait(), wait(long)
Did you look at the FileOutputStream docs? There's no write(OutputStream) method.
Try fos.write(bytes.toByteArray()). Also, bytes.writeTo(fos) may work.