Codeigniter Curl - codeigniter

I am new to CI. I am uploading file from a url(drop box file chooser) but now its uploading to the root directory. I want to know how I can give path to file upload inside the CURL functions.
below is the code .
$curl = curl_init($url);
$file = fopen(basename($url), 'wb');
$file_name =(basename($url));
curl_setopt($curl, CURLOPT_FILE, $file);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_exec($curl);
curl_close($curl);
fclose($file);
Thank you.

That is not possible to set file upload path on curl functon direct.
Please use of drop box api library in codeigniter link below.
drop box api :- https://github.com/jimdoescode/CodeIgniter-Dropbox-API-Library
and follow step.

Related

\PhpOffice\PhpWord issue converting HTML to DOCX

Thank you in advance
i want to convert HTML into DOCX so i used \PhpOffice\PhpWord library in laravel
The code for the same is as below
$html = "<html><body><h1>HELLO DEMO</h1></body></html>";
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html, false, false);
$phpWord->save(public_path('temp/demo.docx'), 'Word2007');
instead of saving the docx, it is showing the HTML on the webpage.
I want to save into a folder
is there anything missed by me, i used this in laravel so require_once "vendor/autoload.php"; might not be required?
You need the
require_once 'vendor/autoload.php';
also add and change
$path = public_path('temp/demo.docx');
$phpWord->save($path, 'Word2007');

Is there a way of parsing information from smarty?

I have three files, a weather.php file which contacts an API and returns weather to my weather.tpl file. However I want to take the contents of the weather.tpl file (which only contains the api response) and post it to another page, any ideas about how I can go about doing this? I'm using smarty version 3.1.33.
Here are my files.
// Weather.php
<?php
$ch = curl_init();
$location = 'MyLocation';
$apikey = 'MyApiKey';
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, 'http://api.openweathermap.org/data/2.5/weather?q='.$location.'&appid='.$apikey);
$output = curl_exec($ch);
curl_close($ch);//Free up system resource
$output = json_decode($output, true);
echo "The weather in ".$location." for MusicWorks Festival will be ".$output['main']['temp'];
?>
//weather.tpl
{block name="weather"}
{/block}
//account.tpl (where I want the contents to end up)
<div>
{block name="weather"}The weather: {/block}
</div>
I have used smarty like this to display both pages.
{extends file="layouts/main.tpl"}
{block name="body"}

I'cant Download Image of post from Facebook

I use the api graph and obtain an image the type:
https://scontent.xx.fbcdn.net/v/t1.0-9/s720x720/27972193_10209727361415594_5326795209597866457_n.jpg?oh=680574d073b0e54d60ed86f9143b05f0&oe=5B1CC7DD
The, I use this code por download the image:
$link_curl = curl_init($image);
curl_setopt($link_curl, CURLOPT_RETURNTRANSFER, true);
$bytes_image = curl_exec($link_curl);
curl_close($link_curl);
$image_name=date("YmdHis")."jpg";
$file = fopen( $directory_local . $image_name,'w');
fwrite($file,$bytes_imagen);
fclose($file);
The result is a file empty.
Help Please

Full youtube palylist using curl ( only half list is dispalying using normal curl )

click to check how the list is loading
i am using the following code to curl youtube but it is showing only top 100 videos in playlist how can i show full playlist videos. There are 180 videos in playlist
( i know about API but i want to use this without youtube API)
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.youtube.com/playlist?list=PL1FO3JrU9Zy-A-q8s4FdzgzNVWsIcTx5q');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$contents = curl_exec ($ch);
echo $contents;
curl_close ($ch);
?>
Which procedure should i follow to get the full playlist ?
I have got my answer.
I need to curl the remaining videos by
Firstly Gather information like url, parameters and request type (post/get) from that ajax request.( by clicking on inspect and the click on network leaflet)
Generate the same request from your php/curl code and you got it.

Display Cross-domain feed RSS in Wordpress site

I need to display cross-domain feeds-rss (XML format)in my site, but i get a error because ajax cross-domain call are not allowed. I've been told about json-p...anyone knows how to use or have some good tutorial?
Thanks
the simplest way is just to create an widget for wordpress or download some kind of like your requirement.
Because json-p load data in JSON format if you want to get data from JSON format then the given link will help you :
getJSON
ajax
or you can access the rss feed with php like given example :
$xml = 'http://blog.webtech11.com/feed';
$doc = new DOMDocument();
$doc->load($xml);
$item = $doc->getElementsByTagName('item');
//$data = array();
for($i=0; $i<=3; $i++){
$title = $item->item($i)->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;
$link = $item->item($i)->getElementsByTagName('link')->item(0)->childNodes->item(0)->nodeValue;
echo '<h2>' . $title . '</h2>';
}
in this example i access latest 4 blog entries..
hope this will help you

Resources