AllToolKits.com Posted December 17, 2013 Report Share Posted December 17, 2013 I am doing a wordpress plugin that fetch blesta pages using curl. Did login to blesta. When i try to access content of the below link using curl domain.com/admin/widget/system_overview/admin_main/ i'm getting content of page domain.com/admin/ not that of domain.com/admin/widget/system_overview/admin_main/ Code is below $tempurl = 'http://domain.com/admin/widget/system_overview/admin_main/'; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, $tempurl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //curl_setopt($ch, CURLOPT_POST, 1); //curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST); // curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $buffer = curl_exec($ch); echo $buffer; curl_close($ch); Quote Link to comment Share on other sites More sharing options...
0 Tyson Posted December 17, 2013 Report Share Posted December 17, 2013 The main widget method is only available via AJAX, and redirects back to the base URI otherwise. You would need to pass in the appropriate AJAX headers and content type. Quote Link to comment Share on other sites More sharing options...
0 jkmorayur Posted December 18, 2013 Report Share Posted December 18, 2013 Show me some examples ? Quote Link to comment Share on other sites More sharing options...
0 AllToolKits.com Posted December 18, 2013 Author Report Share Posted December 18, 2013 @Tyson Do you think we can show the main widget content in wordpress then? is there any technology for that? Quote Link to comment Share on other sites More sharing options...
0 Cody Posted December 18, 2013 Report Share Posted December 18, 2013 @Tyson Do you think we can show the main widget content in wordpress then? is there any technology for that? You could fetch the markup for the system overview widget, but it won't look right outside of Blesta because it will be missing all of the CSS/javascript necessary to render it correctly. Quote Link to comment Share on other sites More sharing options...
0 Tyson Posted December 18, 2013 Report Share Posted December 18, 2013 You could try: curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Requested-With: XMLHttpRequest", "Content-Type: application/json; charset=utf-8")); I haven't tested it, so you may need to play around with it. Quote Link to comment Share on other sites More sharing options...
0 AllToolKits.com Posted December 21, 2013 Author Report Share Posted December 21, 2013 It wroked Thanks Tyson. Quote Link to comment Share on other sites More sharing options...
Question
AllToolKits.com
I am doing a wordpress plugin that fetch blesta pages using curl. Did login to blesta.
When i try to access content of the below link using curl
domain.com/admin/widget/system_overview/admin_main/
i'm getting content of page
domain.com/admin/
not that of
domain.com/admin/widget/system_overview/admin_main/
Code is below
$tempurl = 'http://domain.com/admin/widget/system_overview/admin_main/';
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $tempurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$buffer = curl_exec($ch);
echo $buffer;
curl_close($ch);
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.