saving form data using curl to controller in codeigniter - forms

There is a form and i am getting $_POST data.
The code is this
if (isset($_POST) && $_POST) {
$fields = $_POST;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://example.org/index.php/public/example/SaveExample");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
$output = curl_exec($ch);
}
But the call to controller is not working.what will be the issue.anybody pls help

Related

How I can update old realex payments code to latest 3ds v2?

my old code is using xml and json is like this need to update this to latest 3D Secure v2.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://epage.payandshop.com/epage-remote.cgi");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "payandshop.com php version 0.9");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // this line makes it work under https
$response = curl_exec ($ch);
curl_close ($ch);

How to fetch images using confluence API?

I have created a script that fetches all the articles from https://insuredhq.atlassian.net/ below is the code I have used.
$username = '##########';
$password = '##########';
$url = "https://insuredhq.atlassian.net/wiki/rest/api/content?spaceKey=IUM&id=Completing%20a%20Task&expand=space,body.view,version,container";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "{$username}:{$password}");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
$result = curl_exec($ch);
curl_close($ch);//print_r($result);
$result = json_decode($result);
echo "<pre>";
print_r($result);
I have checked those image src property and they are dynamic urls like /wiki/download/attachments/13303822/Dashboard.png?version=1&modificationDate=1462935137147&api=v2 and even I change them to static urls like https://insuredhq.atlassian.net/wiki/download/attachments/13303822/Dashboard.png?version=1&modificationDate=1462935137147&api=v2 but still they are not being displayed.
For detailed example please check this link http://hunaniinfotech.com/insecuredhq/article.php?id=13303841

Facebook : Post in user wall without SDK

I use below code to post in user wall ,without SDK, it posts successfully , but its not returning the post id , please help me
<?php
$token=$_GET['token'];
$id=$_GET['id'];
$msg = "wooow thats soo possible";
$url = "https://graph.facebook.com/".$id."/feed";
$attachment = array(
'access_token' => $token,
'message' => $msg);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //to suppress the curl output
$result = curl_exec($ch);
curl_close ($ch);
return $result;
?>
I got solution , below code works
<?php
$token=$_GET['token'];
$id=$_GET['id'];
$url = "https://graph.facebook.com/".$id."/feed";
$ch = curl_init();
$attachment = array( 'access_token' => $token,
'message' => "cool winne"
);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
$result= curl_exec($ch);
curl_close ($ch);
?>

How to publish a photo to a Facebook page as a separate story

If I use the Facebook API to publish a photo to a page they appear as single story.
$args = array(
'message' => '',
);
$args["picture"] = '#' . realpath($file);
$ch = curl_init();
$url = 'https://graph.facebook.com/me/photos?access_token='.$token;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$data = curl_exec($ch);
If I publish from Facebook they appear correctly as a single story for each picture.
How to do this programmatically?

Utf-8 url get with curl

i am trying to visit some urls with non latin characters using curl, the problem is when i visit i get no response. My browser has no problem visiting them, i checked out the string transformations and it seems i am visiting
"http://www.linkedin.com/pub/j-rgen-a-tr-ff/7/606/68a"
while my browser visits
"http://se.linkedin.com/pub/j%C3%B6rgen-a-tr%C3%A4ff/7/606/68a"
How do i convert that string so the curl succeeds?
function hitFormGet($loginURL, $loginFields, $referer,$cookieString)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
//curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
//curl_setopt( $ch, CURLOPT_COOKIE,$cookieString);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_VERBOSE, 1 );
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate,sdch');
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_HEADER, false);
//curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, "Googlebot/2.1 (+http://www.googlebot.com/bot.html)");
curl_setopt($ch, CURLOPT_URL, $loginURL.$loginFields);
curl_setopt($ch, CURLOPT_REFERER, $referer);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $loginFields);
$ret = curl_exec($ch);
curl_close($ch);
return $ret;
}
$res=hitFormGet("http://se.linkedin.com/pub/j%C3%B6rgen-a-tr%C3%A4ff/7/606/68a","","","");
It looks like you are visiting linkedin from Sweden. That's why you are redirected to se.linkedin.com. To convert URL as expected you can apply urlencode() on your dynamic url part as in your example on: j-rgen-a-tr-ff/7/606/68a.
It should work.