SimplePie document parse error - laravel

I am trying to implement Simplepie in my laravel application to parse feeds, but when I do, I get this error:
This XML document is invalid, likely due to invalid characters. XML
error: Not well-formed (invalid token) at line 1, column 1
The feed is this one: https://www-304.ibm.com/connections/blogs/roller-ui/rendering/feed/PSIRT/entries/atom?search=cn4093&t=entry&f=all&lang=en_us and it works great in the demo app, but fails locally.
Here what I am doing:
$feed = new SimplePie();
$feed->set_feed_url("https://www-304.ibm.com/connections/blogs/roller-ui/rendering/feed/PSIRT/entries/atom?search=cn4093&t=entry&f=all&lang=en_us");
$feed->enable_cache(true);
$feed->set_cache_location(storage_path().'/cache');
$feed->set_cache_duration(60*60*12);
$feed->set_output_encoding('utf-8');
$feed->force_feed(true)
$feed->init();
Can someone help me ?

The issue seems to be because of the SSL (https) connection you are trying to load. Please read this: https://github.com/simplepie/simplepie/issues/236
It includes the fix to download the RSS using cURL and include it's result into the SimplePie class to parse.
UPDATE:
Read the comment by manishbhatias commented on 20 Jul 2011, on: https://github.com/simplepie/simplepie/issues/82
sharing the same issue you have. He believes it had something to do with the method SimplePie uses to urlencode parameters in the URL. You could create a proxy PHP script and see if that solves the issue for you.
<?php
echo file_get_contents('https://www-304.ibm.com/connections/blogs/roller-ui/rendering/feed/PSIRT/entries/atom?search=cn4093&t=entry&f=all&lang=en_us');
?>

Related

unable to generate PDF from spatie bowsershot

i have installed browsershot in my laravel project
I have installed puppeteer, installed chromium , my npm version is updated, but still i am unable to get the PDF of my simple html input , i have tried to take screenshot by URL method and save as image(It works), but my requirement is to generate PDF of my html.
This is my code in controller
$output=Browsershot::html($html)
->setNodeModulePath("/var/www/html/ProjectName/node_modules/")
->setChromePath("/usr/bin/chromium-browser")
->setNodeBinary('/usr/local/bin/node')
->setNpmBinary('/usr/local/bin/npm')
->showBackground()
->noSandbox()->timeout(60)
->save(public_path("DevTest.pdf");
Error Message:
"message": "The process "PATH=$PATH:/usr/local/bin NODE_PATH='/var/www/html/ProjectName/node_modules/' /usr/local/bin/node '/var/www/html/benesprint/vendor/spatie/browsershot/src/../bin/browser.js' '{"url":"file:\/\/\/tmp\/1933874416-0068512001600765779\/index.html","action":"pdf","options":{"path":"\/var\/www\/html\/ProjectName\/public\/DevTest.pdf","args":["--no-sandbox"],"viewport":{"width":800,"height":600},"displayHeaderFooter":false,"executablePath":"\/usr\/bin\/chromium-browser","timeout":60000,"printBackground":true}}'" exceeded the timeout of 60 seconds.",
**i would be grateful if you can help me out.**
i have similiar problem when browsershot inside container. and my step to resolve is like this:
Manual generate PDF from html using laravel tinker. if there is an error, try reinstall chromium and puppeteer library.
If success, then try remove all css and javascript links from html, and check for the result.
If success, then add --proxy-server="direct://" and --proxy-bypass-list=* into browsershot args
If step 3 is not working, then you can put css and javascript directly into view template or using php code to inclue those files like
<?php include public_path('css/styles.css') ?>

ion_auth library syntax error, unexpected ','

i am using ion auth library in codeigniter when i integrated it and accessing from localhost it showing me error as mentioned in image.
when i opened the library code line 141 the code is:
$user = $this->where($identifier, 'ion_auth'), $identity)->where('active', 1)->users()->row(); //changed to get_user_by_identity from email
now my question is the ) symbol after 'ion_auth' is ok or wrong? when i removes this library code works fine.
This has been fixed. Please pull the latest code from github.
I am not sure what you are trying to do, assuming you are the one who modified the library.
$this->where($identifier, 'ion_auth'), $identity)
The where method call is terminated by the parenthesis that follows 'ion_auth'.
This would be legal
$this->where($identifier, 'ion_auth') ->where('active', 1)->users()->row();
Assuming that is what you want.
this issue was exist when i downloaded library but later after mentioning here Ben Edmunds has updated code and now the correct code is
$user = $this->where($identifier, $identity)->where('active', 1)->users()->row();
at line 141 which is working for me.

Localhost returns 404.3 when fetching json through ajax (Windows 8.1)

So I have been getting the infamous 404.3 error when trying to use AXAJ to access a .json file launching the site (or more of a test app hehe) through WebMatrix on localhost.
Yes, I am aware of the IIS configuration. I am on Windows 8.1(x64), so I had to even turn on MIME types functionality separately. I configured a MIME type for .json with application/javascript. Then I went and added a handler to *.json, pointed it to C:\WINDOWS\system32\inetsrv\asp.dll. I set the verbs to GET and POST (those are what I use in my ajax function). I also tried unchecking the "Invoke the handler only if request is mapped to..." to no avail.
I am using one function to send data to PHP file which writes it to the JSON file and then another to fetch data from the JSON file directly. Writing through PHP works. Fetching doesn't. I am completely at a loss, does anyone have any ideas? The code I am using to fetch the data is your bog-standard ajax:
function getDate(path, callback) {
var httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function() {
if (httpRequest.readyState === 4) {
if (httpRequest.status === 200) {
var data = JSON.parse(httpRequest.responseText);
if (callback) callback(data);
}
}
};
httpRequest.open('GET', path);
httpRequest.send();
}
When I host this on my server space, it works totally fine. But I want to get it to work locally for testing purposes as well.
If writing to the file works but fetching doesn't work. Then you should check for the link of the file.
The error 404 as the name refers to, is an error for the file name. There isn't any other sort of error, even the Ajax request is working fine and giving the error 404 (file not found). So the only thing that you can do is, to make sure that while fetching the data, you use the correct link.
Here can be a help, when you send the Request through Ajax, there is a Network tab in your Browser's console. Open it, and look for the request. It would in red color denoting an error and click it. You'll see that the link you're providing isn't valid.
Look for the errors in the File Link then and update it.
The lengths I go to, to clean up my profile...
When you require a JSON format, or any file for that matter you have to specify in your request what data type you need, IIS will not make any assumptions. So
xhr.setRequestProperty('Content-Type', 'application/json');
is something one must not forget. I set also the X-Requested-With header. Note that to reproduce this issue I used IIS that is installed on Windows 10 Pro, so not exactly the same system (3 years later - holy crap!).

Getting Phonegap app to communicate to Codeigniter Server in Android and Access-Control-Allow-Origin error

I am extremely new to using phonegap,codeigniter and jQuery Mobile (My first project) and have currently created an app with jQuery Mobile on the Client side and on the Server side I used the Codeigniter framework to create a RESTful API. Now when I am developing locally the app with in the browser (not yet using phonegap) communicates just fine with the API and no problems occur.
I placed the Codeigniter API on a server yesterday and I am now encountering 2 problems:
The App which was built using jQuery Mobile keeps getting the
following error:
Origin localhost is not allowed by Access-Control-Allow-Origin.
Now I have done some reading up and most people say to use jsonp instead of json and also to use the following on the Server Side:
$CI->output->set_header("Access-Control-Allow-Origin: *");
$CI->output->set_header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
$CI->output->set_status_header(200);
$CI->output->set_content_type('application/json');
Now my problem is I'm not entirely sure which one is used to fix the problem, weather it is both that need to be implemented etc. If they need to be fixed, how is it done? Is there a place that is well documented that can teach me how to deal with this problem, preferably I would like some where to read up on so I can learn?
The second problem is when I place the jQuery Mobile app into
phonegap and build it for Android. The app fails to get the
data from the server. Now is the reason for this because of the cross
domain error above or is this problem different? I also did some
reading up in this section as well and to my Android config.xml I
added the following code:
But I'm I still can't pull anything from the server. Like I said I'm a bit of a newbie but would really appreciate some help in this matter. Also I am aware that I haven't posted code but based on the comments I'll post which ever code the community needs to help solve this problem, just simply specify which code. Thank you for the help in advance!
About the Access-Control-Allow-Origin problem, I faced the same error and solved by placing this line <?php header('Access-Control-Allow-Origin: *'); ?> in the index.php which is in the root of the project.
This question hasn't been answered 100% but for now thanks to the help of #Niloy Saha, to fix the Access-Control-Allow-Origin error with with the Codeigniter RESTful frame work simply go to your controller in the Controller folder and right at the top paste;
header('Access-Control-Allow-Origin: *');
This then should allow you to communicate from the browser to the server and be able to get a response. After a good for hours of trying I managed to fix my problem. With in the Android project in the res/xml folder there is a file called config.xml. In that file be sure to have the following code:
<access origin="http://10.0.2.2*" subdomains="true"/>
and also make sure you have the following:
<uses-permission android:name="android.permission.INTERNET" />
in your AndroidManifest.xml. For me that seemed to get everything to work
I did similar thing as yours, Zend FW with API on server and jQuery Mobile App.
I've used JSONP, didn't use any Access-Control-Allow-Origin headers.
I have a method in my controller:
function returnData($data) {
header('Content-type: text/javascript');
echo $_GET['callback']. '('. json_encode($data). ')';
die();
}
At the end of API call i use it to return data.
Getting data in jQuery:
$.ajax({
dataType: "jsonp",
url: url,
data: {someparam: 'value'},
success: function(data) { /* ur data is here */ }
});

Using WSDL With Ruby

I'm getting this error:
WSDL::XMLSchema::Parser::UnknownElementError
unknown element: {}HTML
at 'new'
when I consume webservices using Ruby. Here is the code snippet:
require 'soap/wsdlDriver'
wsdl = url
driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
driver.options["protocol.http.basic_auth"] << [url, user_name, password]
the url points to a well-formed xml.
Any solutions?
Can you share the wsdl file? Maybe that would help us answering it better.
In any case, I'd suggest generating the Driver classes first using wsdl2ruby. And then loding them in your Ruby file (through require). Examples (from the man pages):
# For server side:
$ wsdl2ruby.rb --wsdl myapp.wsdl --type server
# For client side:
$ wsdl2ruby.rb --wsdl myapp.wsdl --type client
If you load the URL in a web browser, does it get redirected to a different location?
In my experience, one reason the error "unknown element: {}HTML" comes up is the WSDL parser is trying to parse the HTML portion of the HTTP redirect and failing to do so. Therefore, you should deal with the redirect yourself (either in code or manually) and give the WSDL driver the final URL.

Resources