It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I want a content type having a field "FB URL" that get the URL of a Facebook Event and that when people load a node of this type, the content of the facebook event is retrieved through FB API. It cannot be retrieved from the database because the content must be up to date with the one on facebook.
So far, I created a module with node_load() to add content while the node is loaded but I don't know what function to call from FBOauth module to do so... Before that, I tried with a simple file_get_contents(); that worked well until the access token from the FB App expired and didn't know how to get a new one dynamically.
I think I'm getting lost so could anyone guide me on how to do that?
Thanks a lot!
Ok I found (I don't understand the -1 though; the question aimed to know if I was on the right track to do it):
function fb_event_crawler_node_load($nodes, $types) {
foreach ($nodes as $node) {
if ($node->type=="event"){
$fb_url = $node->field_event_url['und'][0]['value'];
$url = parse_url($fb_url);
if (!$url['host'] == 'www.facebook.com'){
echo t('This is not a Facebook URL');
}
$path_exploded = explode("/", $url['path']);
if (!$path_exploded[1] == 'events'){
echo t("This is not a Facebook event page!");
}
$fb_event_id=$path_exploded[2];
// dpm($path_exploded);
$app_id = isset($app_id) ? $app_id : variable_get('fboauth_id', '');
$app_secret = isset($app_secret) ? $app_secret : variable_get('fboauth_secret', '');
$app_token_url = "https://graph.facebook.com/oauth/access_token?"
. "client_id=" . $app_id
. "&client_secret=" . $app_secret
. "&grant_type=client_credentials";
$response = file_get_contents($app_token_url);
$params = null;
parse_str($response, $params);
$access_token=$params['access_token'];
//echo($params['access_token']);
$fbquery = fboauth_graph_query($fb_event_id."/", $access_token);
dpm($fbquery);
}
}
}
Related
I've been looking around for an answer to this question but all the related questions seem to be seeking to prevent this functionality.
Simply put, how do I make a bootstrap modal appear on the first two pages of a users visit? Right now I have a modal going with some simple cookie script that makes it appear once per visit. Is this something that is possible using cookies or some other method?
Not sure if this is helpful, but this is the cookie code i'm currently using -
jQuery(document).ready(function($) {
setTimeout(function(){
if(!jQuery.cookie('modalShown')) {
jQuery("#myemailmodal").modal('show');
jQuery.cookie('modalShown', true);
}
}, 20000);
you can use sessionStorage and make a counter with it:
$(document).ready(function(){
let counter = sessionStorage.getItem('counter');
counter++;
sessionStorage.setItem('counter',counter);
if ( counter <= 2 )
launchmodal();
})
I'm sorry for my bad english, I have a little problem but i don't understand how to solve it.
When I do SQL update, I have one question mark ? which appears in the field
Here is the code
public function FooterUpdate($footer_text, $client_id) {
$connection = new Connection;
$db = $connection->openConnection();
$req = $db->prepare("UPDATE jcmsi_parametre SET footer_text = :footer_text WHERE client_id = :client_id");
$req->bindValue(':footer_text', $footer_text);
$req->bindValue(':client_id', $client_id);
$req->execute();}
The text before insert
<p><em class="fa fa-arrow-right"></em>Contact</p>
The text after insert
<p><em class="fa fa-arrow-right"></em><a href="contact.php" >Contact?</a></p>
After the insert query, I have the word Contact with the question mark ?.
I try echo $footer_text just before update and the text is ok, but not in sql
If you have an idea
Thank you
Didier
I wish I can find some assistance with my code.
I have set up a Database on mySQL, and connected it to Django REST. Those both work as expected, and I can access the REST with Firefox REST Client with it returning the correct tables from the database.
I have started working for user interface with html and javascript and I have encountered a problem I am unable to solve. I am a student, and this is part of my school work, but unfortunately my teachers are unavailable at the moment due summer vacations and I am eager to continue my project. Hence I am askin for Your assistance.
As I have tested the Django REST through Firefox REST Client, I am sure the database and REST service is not at fault so here we come to my code.
I seem to be able to get connection to the REST Service, giving me code 200 and state 4 (pictures linked underneath)
ReadyStateChange + ReadyState console.logs
Picture 2 shows that my GET request gets stuck on OPTIONS, instead of executing the correct request.
200 OPTIONS
However I am unable to pull data out, giving me 'Content-Length: 0'.
Originally I thought the issue would be cross-domain request problem until my fellow student said he does not think it is, however he was unable to find solution for my code either.
I am trying to find reason and workaround for this error, and if you guys do have idea why this is happening I would deeply appriciate your help!
Here is my code:
<div id="demo"></div>
<script>
loadData() //function kutsu
function loadData(){
if (window.XMLHttpRequest) {
// code for modern browsers
xmlhttp = new XMLHttpRequest();
} else {
// code for old IE browsers
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
var url = "http://127.0.0.1:8000/vamkrs/";
xmlhttp.open("GET", url, true);
xmlhttp.withCredentials = true;
xmlhttp.setRequestHeader("Authorization", "Basic " + btoa("username:password"));
xmlhttp.send();
setTimeout(xmlhttp.onreadystatechange = function() {
console.log(this.status);
console.log(this.readyState);
if (this.readyState == 4 && this.status == 200) {
var myData = JSON.parse(this.responseText);
document.getElementById("demo").innerHTML = myData.responseText(); }
},1500);
/*
xmlhttp.onreadystatechange = function(){
console.log(this.status);
if (this.readyState == 4 && this.status == 200) {
var myData = JSON.parse(this.responseText);
document.getElementById("demo").innerHTML = myData.responseText();}
}; */
}
</script>
Ps. Sorry, English is not my native language so some spelling mistakes might have been made
Pss. First time posting here, I apologize if mistakes were made on the post
I'm searching for a tutorial or documentation where is explained the webservice use of Prestashop (v1.5.6.0).
I'd like simply add or edit (update) o product.
There is'not a tutorial clean or with example about use of prestashop's api.
Coul you help me please ?
For example, i'd like add object a:
define('PS_SHOP_PATH', 'http://localhost/myshop'); // Root path of your PrestaShop store
define('PS_WS_AUTH_KEY', '****'); // Auth key (Get it in your Back Office)
require_once('api/PSWebServiceLibrary.php');
$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
$opt = array('resource' => 'products');
Now, how can i set my values for a new object ? In the example you can insert only required value.
Could you help me ?
And for update ?
Please ,no linked me Prestashop documentation, i have already read it, i'm asking your help.
Thanks and excuse for my bad english.
Here is the link to the official documentation. You will find there all the information you need.
Basically, you'll need to create an XML that represents the object you'd like to PUT.
Lets say you want to create a new category.
First, you need to get the schema :
$xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/categories?schema=blank'));
Which is something like this :
<prestashop>
<category>
</category>
</prestashop>
Then you'll have to set the content of the xml ($resources)
$resources = $xml->children()->children();
$resources->active = true;
$resources->..........
etc.
Finally,
try
{
$opt = array('resource' => 'categories');
$opt['postXml'] = $xml->asXML();
$xml = $webService->add($opt);
}
catch (PrestaShopWebserviceException $e)
{
echo 'Something went wrong: '.$e->getMessage();
}
I need to get the content of an Article which is on my Joomla website. In order to do this, I was planning to write a simple PHP webservice to get the content (HTML) of my article. But I just don't know how to do this.
I'm new in Joomla, web developping and web services. I just want to get the content of my article in order to display it in my ruby on rails site. Can anyone explain how I can do this?
Well, here is at least a small contribution that should help to get you going: the attached code can be called with "?id={ID of article you want to retrieve}" and it displays the entire object on screen.
Next steps: pick out the pieces you're interested in and return these...
<?php
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
$username="*** insert username ***";
$password = "*** password here ***";
if (!defined('_JDEFINES')) {
define('JPATH_BASE', dirname(__FILE__));
require_once JPATH_BASE.'/includes/defines.php';
}
require_once JPATH_BASE.'/includes/framework.php';
// Mark afterLoad in the profiler.
JDEBUG ? $_PROFILER->mark('afterLoad') : null;
// Instantiate the application.
$app = JFactory::getApplication('site');
// Initialise the application.
$app->initialise();
$app ->login(
array('username'=>$username,
'password'=>$password),
array('remember' => true));
$dbo = JFactory::getDBO();
$id=$_GET["id"];
$art = JTable::getInstance('Content');
$art->load($id);
echo "<pre>";
var_dump($art);
echo"</pre>";
?>