I'm currently developing an iOS app along with a Wordpress site with the bbPress plugin.
I would like to allow any user to easily post links with custom schemes in the forum like :
myappname://badebidobudy/fdjlkqsfj
I saw that in bbPress an admin can indeed post a link like this :
Da link
and bbPress tells me why :
Your account has the ability to post unrestricted HTML content.
But when an anonymous user wants to do this, the custom scheme is removed and the resulting html code is :
Da link
So my question is : how can I configure (or tweak) Wordpress to at least accept my url scheme or even recognize a raw link with a custom scheme ?
After reading the comments of : https://developer.wordpress.org/reference/functions/esc_url/
I ended implementing a small plugin, here is its php code (the protocol I add is "newzik") :
<?php
/**
* Plugin Name: NZK links support
* Plugin URI: http://newzik.com/
* Description: Adds support to newzik:// links
* Version: 1.0
* Author: Pierre Mardon
* Author URI: http://newzik.com/
* License: None
*/
/**
* Extend list of allowed protocols.
*
* #param array $protocols List of default protocols allowed by WordPress.
*
* #return array $protocols Updated list including new protocols.
*/
function wporg_extend_allowed_protocols( $protocols ){
$protocols[] = 'newzik';
return $protocols;
}
add_filter( 'kses_allowed_protocols' , 'wporg_extend_allowed_protocols' );
?>
Related
I want to display information about links in the YouTube profile in a text document, I tried to do it through the requests library, but Google gave links to privacy and security, I did not find information about this in the YouTube API documentation. Who knows, you can help with this
This isn't possible to get using the YouTube API, I actually found myself needing to do the same thing as yourself and was not able to because the YouTube API lacked the necessary functionality (Hopefully, It will be added soon!)
I see you mentioned Python, My only solution is in Node but I will do a large explanation and you can base your code off of it. In order to get the banner links without the YouTube API, we need to scrape the data, since YouTube uses client-side rendering we need to scrape the JSON configuration from the source.
There's a variable defined inside a script called ytInitialData which is a big JSON string with a massive amount of information about the channel, viewer, and YouTube configurations. We can find the banner links by parsing through this JSON link.
const request = require("request-promise").defaults({
simple: false,
resolveWithFullResponse: true
})
const getBannerLinks = async () => {
return request("https://www.youtube.com/user/pewdiepie").then(res => {
if (res.statusCode === 200) {
const parsed = res.body.split("var ytInitialData = ")[1].split(";</script>")[0]
const data = JSON.parse(parsed)
const links = data.header.c4TabbedHeaderRenderer.headerLinks.channelHeaderLinksRenderer
const allLinks = links.primaryLinks.concat(links.secondaryLinks || [])
const parsedLinks = allLinks.map(l => {
const url = new URLSearchParams(l.navigationEndpoint.commandMetadata.webCommandMetadata.url)
return {
link: url.get("q"),
name: l.title.simpleText,
icon: l.icon.thumbnails[0].url
}
})
return parsedLinks
} else {
// Error/ratelimit - Handle here
}
})
}
The way the links are scraped is as follows:
We make a HTTP request to the channel's URL
We parse the body to extract the JSON string that the banner links are inside using split
We parse the JSON string into a JSON object
We extract the links from their JSON section (It's a big JSON object data.header.c4TabbedHeaderRenderer.headerLinks.channelHeaderLinksRenderer
Because there are two types of links (Primary, the one that shows the text and secondary, links that don't show the text) we have to concatenate them together so we can map through them
We then map through the links and use URLSearchParams to extract the q query parameter since YouTube encrypts their outgoing links (Most likely for security reasons) and then extract the name and icon too using their appropriate objects.
This isn't a perfect solution, should YouTube update/change anything on their front end this could break your program easily. YouTube also has rate limits for their software if you're trying to mass scrape you'll run into 429/403 errors.
I am trying to integrate an eBay SDK developed by David Sadler which is in GitHub. But I got stuck on connection part itself. I am getting app token with http://localhost/ebay-sdk-examples/oauth-tokens/01-get-app-token.php with my production credentials.
But when I hit, http://localhost/ebay-sdk-examples/oauth-tokens/02-get-user-token.php it gives me this error:
[error] => invalid_grant
[error_description] => the provided authorization grant code is invalid or was issued to another client
all The codes are available in the SDK link. Incase you need here is the code snippet
<?php
/**
* Copyright 2017 David T. Sadler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Include the SDK by using the autoloader from Composer.
*/
require __DIR__ . '/../vendor/autoload.php';
/**
* Include the configuration values.
*
* Ensure that you have edited the configuration.php file
* to include your application keys.
*/
$config = require __DIR__ . '/../configuration.php';
/**
* The namespaces provided by the SDK.
*/
use \DTS\eBaySDK\OAuth\Services;
use \DTS\eBaySDK\OAuth\Types;
/**
* Create the service object.
*/
$service = new Services\OAuthService([
'credentials' => $config['production']['credentials'],
'ruName' => $config['production']['ruName'],
'sandbox' => false,
]);
$token = $config['production']['testToken']; ** This is the app token I get with http://localhost/ebay-sdk-examples/oauth-tokens/01-get-app-token.php **
/**
* Create the request object.
*/
$request = new Types\GetUserTokenRestRequest();
$request->code = $token;
// $request->code = 'v^1.1#i^1#I^3#r^1#p^3#f^0#t^Ul41XzA6MkIzRjJFRjA1MENDMzZCQjlGMjVERkYyMkMxMTRBM0VfMV8xI0VeMjYw';
/**
* Send the request.
*/
$response = $service->getUserToken($request);
echo '<pre>';
print_r($response);
echo '<pre>';
exit;
/**
* Output the result of calling the service operation.
*/
printf("\nStatus Code: %s\n\n", $response->getStatusCode());
if ($response->getStatusCode() !== 200) {
printf(
"%s: %s\n\n",
$response->error,
$response->error_description
);
} else {
printf(
"%s\n%s\n%s\n%s\n\n",
$response->access_token,
$response->token_type,
$response->expires_in,
$response->refresh_token
);
}
If there are simple codes to without using any SDK to connect to eBay with OAuth, its what I am searching for.
I am also currently working with this SDK.
My understanding is you should place the url:
http://localhost/ebay-sdk-examples/oauth-tokens/02-get-user-token.php
As your Your auth accepted URL1 in the developer.ebay.com, under Get a Token from eBay via Your Application.
Where you are setting $token this should be set to $_GET['code'] as when testing the sign-in and accepting you should be redirected to the above URL with a ?code=xxxx parsed back to it.
The value your currently setting to $token should be set as the value of your authToken within your credentials.
Hope that helps.
eBay Token generation can be achieved using our custom PHP/.NET scripts. eBay API documentation having many references
https://viewdotnet.wordpress.com/2011/12/20/ebay-token-generation/
The above link includes all the required details to generate eBay Auth. token
I have an ASP.NET MVC application. When I start the application I get the error here:
SignalR: Connection must be started before data can be sent. Call .start() before .send()
No transport could be initialized successfully. Try specifying a different transport or none at all for auto initialization.
I am not at all using SignalR but I get that error related to SignalR. I am not sure why ...
But when I start my application, it loads browserlink file (please see below) which has references to SignalR. Is this creating problem? Please help.
typeof JSON!="undefined"&&(window._vwdJSON=JSON),typeof define!="undefined"&&(window._vwdDefine=define,define=null),typeof window.onbeforeunload!="undefined"&&(window._vwdonbeforeunload=window.onbeforeunload)
;
/* NUGET: BEGIN LICENSE TEXT
*
* Microsoft grants you the right to use these script files for the sole
* purpose of either: (i) interacting through your browser with the Microsoft
* website or online service, subject to the applicable licensing or use
* terms; or (ii) using the files as included with a Microsoft product subject
* to that product's license terms. Microsoft reserves all other rights to the
* files not expressly granted by Microsoft, whether by implication, estoppel
* or otherwise. Insofar as a script file is dual licensed under GPL,
* Microsoft neither took the code under GPL nor distributes it thereunder but
* under the terms set out in this paragraph. All notices and licenses
* below are for informational purposes only.
*
* NUGET: END LICENSE TEXT */
var JSON;JSON||(JSON={}),(function(){"use strict";function i(n){return n<10?"0"+n:n}function f(n){return o.lastIndex=0,o.test(n)?'"'+n.replace(o,function(n){var t=s[n];return typeof t=="string"?t:"\\u"+("0000"+n.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+n+'"'}function r(i,e){var h,l,c,a,v=n,s,o=e[i];o&&typeof o=="object"&&typeof o.toJSON=="function"&&(o=o.toJSON(i)),typeof t=="function"&&(o=t.call(e,i,o));switch(typeof o){case"string":return f(o);case"number":return isFinite(o)?String(o):"null";case"boolean":case"null":return String(o);case"object":if(!o)return"null";n+=u,s=[];if(Object.prototype.toString.apply(o)==="[object Array]"){for(a=o.length,h=0;h<a;h+=1)s[h]=r(h,o)||"null";return c=s.length===0?"[]":n?"[\n"+n+s.join(",\n"+n)+"\n"+v+"]":"["+s.join(",")+"]",n=v,c}if(t&&typeof t=="object")for(a=t.length,h=0;h<a;h+=1)typeof t[h]=="string"&&(l=t[h],c=r(l,o),c&&s.push(f(l)+(n?": ":":")+c));else for(l in o)Object.prototype.hasOwnProperty.call(o,l)&&(c=r(l,o),c&&s.push(f(l)+(n?": ":":")+c));return c=s.length===0?"{}":n?"{\n"+n+s.join(",\n"+n)+"\n"+v+"}":"{"+s.join(",")+"}",n=v,c}}typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+i(this.getUTCMonth()+1)+"-"+i(this.getUTCDate())+"T"+i(this.getUTCHours())+":"+i(this.getUTCMinutes())+":"+i(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var e=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,o=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,n,u,s={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},t;typeof JSON.stringify!="function"&&(JSON.stringify=function(i,f,e){var o;n="",u="";if(typeof e=="number")for(o=0;o<e;o+=1)u+=" ";else typeof e=="string"&&(u=e);t=f;if(f&&typeof f!="function"&&(typeof f!="object"||typeof f.length!="number"))throw new Error("JSON.stringify");return r("",{"":i})}),typeof JSON.parse!="function"&&(JSON.parse=function(n,t){function r(n,i){var f,e,u=n[i];if(u&&typeof u=="object")for(f in u)Object.prototype.hasOwnProperty.call(u,f)&&(e=r(u,f),e!==undefined?u[f]=e:delete u[f]);return t.call(n,i,u)}var i;n=String(n),e.lastIndex=0,e.test(n)&&(n=n.replace(e,function(n){return"\\u"+("0000"+n.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(n.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"#").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return i=eval("("+n+")"),typeof t=="function"?r({"":i},""):i;throw new SyntaxError("JSON.parse");})})()
;
* ASP.NET SignalR JavaScript Library v2.0.2; Copyright (C) Microsoft Corporation; https://github.com/SignalR/SignalR/blob/master/LICENSE.md
*
* NUGET: END LICENSE TEXT */
/*!
* ASP.NET SignalR JavaScript Library v2.0.2
* http://signalr.net/
*
* Copyright (C) Microsoft Corporation. All rights reserved.
*
*/
You may not be using SignalR, but yes, browser link uses SignalR.
According to the documentation:
Browser Link is enabled by default. There are several ways to disable
it: In the Browser Link dropdown menu, uncheck Enable Browser Link.
I'm trying to implement Twitter conversion tracking using Google Tag Manager (GTM). In GTM there is a tag type of Twitter Universal Website Tag which has lots of extra purchase related parameters.
value : transaction price, usually in USD or GBP.
currency : e.g. GBP
order_id : e.g. INVOICE-5678
num_items : Number of items that were purchased.
content_ids : comma seperated list of item ids, ie. ['prod_1','prod_2','prod_3']
content_category : Category of the page or product
When I use the twitter pixel helper, none of these values is being registered even though they're being passed through from the dataLayer.
Does anyone know if Twitter uses these extra parameters when tracking conversions? I cannot see anything about in twitter GTM documentation.
I've been to this page:-
Twitter Help Page
And when it gets to the "For more information about tag events and required parameters, see the Twitter Help Centre".
The standard twitter conversion tracking code only allows for two params to be tracked.
tw_sale_amount and tw_order_quantity
Are these really the only parameters it takes?
I found that the GTM Universal Twitter Tag does work, but I had implimented the content_ids incorrectly. NOTE : If content_ids are not working for your twitter tag, it usually means your whole twitter tag is not working.
It needed to be a json_encoded array to work. All working correctly since I made this change. It also fixed my Facebook Tag integration.
<!-- language: lang-php -->
/* EXAMPLE */
$content_ids = [];
foreach ( $product_items as $product_item_data ) {
$content_ids[] = $product_item_data['product_item_sku'];
}
$tag_manager_data = array('content_ids' => json_encode( $content_ids ),
'price_data' => $price_data,
'currency' => $currency,
'item_count' => $item_count );
Then in your view / html file you can do the following:-
<!-- language: lang-js -->
<script>
var tag_manager_data = <?php echo json_encode( $tag_manager_data ); ?>;
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'value' : tag_manager_data.price_data,
'currency' : tag_manager_data.currency,
'content_category' : 'Checkout',
'content_ids' : tag_manager_data.content_ids,
'event' : 'InitiateCheckout'
});
</script>
Hope this helps someone. The above code is representative only and clearly needs more error checking.
In Contao 3.5.9
I have uploaded to new server and am using a different domain from the original installation. I am also using https://
Many of the resources needed are not being loaded because the system has the base url set to http://
It is using the correct domain name in the base url, but the wrong protocol.
I cannot login to the admin.
I searched Google (not much there about Contao) and found this: http://blog.qzminski.com/article/move-the-contao-to-another-server.html
reading it, it seems that the base url is set in the admin, which means it can be found somewhere in the db.
I have search the DB dump but cannot find it.
How can I change the protocol of the base url?
Contao uses the following to determine whether the current request is done via SSL or not ยป \Environment::get('ssl'):
/**
* Return true if the current page was requested via an SSL connection
*
* #return boolean True if SSL is enabled
*/
protected static function ssl()
{
return ($_SERVER['SSL_SESSION_ID'] || $_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1);
}
It is possible that your server environment does not set either of these $_SERVER globals. This can be the case if you are using an SSL proxy for example.
If that is the case for you, then you can extend the SSL detection by inserting
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO'])
{
$_SERVER['HTTPS'] = 1;
}
into your /system/config/initconfig.php. See https://github.com/contao/core/issues/7542 for example (only German though).