linkedin canot create sponsored Share - linkedin

when i used "https://api.linkedin.com/v2/shares" to create a Share for sponsored share,and got a Share id.
I post
{
\"campaign\": \"urn:li:sponsoredCampaign:{$campaign_id}\",
\"reference\": \"urn:li:share:{$share_id}\",
\"status\": \"ACTIVE\",
\"type\": \"SPONSORED_STATUS_UPDATE\",
\"variables\": {
\"data\": {
\"com.linkedin.ads.SponsoredUpdateCreativeVariables\": {}
}
}
} to create sponsored .but it return :
{"message":"Validation failed because [{reason=INVALID_VALUE_FOR_FIELD, field=reference, batchIndex=0, type=INVALID_VALUE, message=/reference cannot be set to urn:li:share:6316476667095322625, parameters={field=/reference, value=urn:li:share:6316476667095322625, key=}}]","status":400}
but ,for waiting few second,I used the same content create again ,I work and return me the "X-LinkedIn-Id".
I've compared two things, it's the same .
does it has something limited in create sponsored share?

I figured it out ,when create a share ,It must wait for 30 second at least .and then ,you will create sponsored share success!

Related

Is it possible to get the placeCategory id of a place? (iOS Here SDK Explore Edition)

I want to use the category id of the place described here: https://developer.here.com/documentation/geocoding-search-api/dev_guide/topics-places/places-category-system-full.html.
How can i get it? Via the searchEngine?
I tried:
if !places.isEmpty {
for place in places {
let placeIdQuery = PlaceIdQuery(place.id)
searchEngine.search(placeIdQuery: placeIdQuery, languageCode: .deDe, completion: onFollowUpSearchCompleted)
}
}
But i only get the same places.
Found it.
Every Place has the optional details -> category.

Filter posts by custom fields

I want to give users the ability to sort posts themselves using some filter links on the side, so for instance:
To sort by title: www.example.com/?orderby=title&order=asc
To sort by date: www.example.com/?orderby=date&order=asc
So I want to be able to sort posts using a custom field called "shares" that returns a number , and I use Advanced Custom Fields plugin to generate that field, but not sure how I can generate such query and more importantly, giving a link to apply it if possible.
thanks in advance.
Try this simple code and after making sure that it works, you need to improve it yourself (adding conditions f.e.)
add_action('pre_get_posts','order_post_filter');
function order_post_filter($query){
//then you will need to add some condition here
if (isset($_GET["orderby"]) and isset($_GET["order"])){
$order=$_GET["order"]=='DESC'?'DESC':'ASC';
$query->set('order',$order);
if ($_GET["orderby"]=='date'){
$orderby='date';
}
elseif ($_GET["orderby"]=='title'){
$orderby='title';
}
else {
$query->set('meta_key',$_GET["orderby"]);
$orderby='meta_value';
}
$query->set('orderby',$orderby);
}
}

How to update user's feed in Firebase Database when the user follows someone

I am designing an application that each user will a have a timeline (aka feed) based on the posts of his/her followings. In my database, I am keeping the user timeline posts as Shared Key. So each ID in the feedsubtree belong to a post of someone the user following.
"users": {
"userId-1": {
"userName": "Namey McNameface",
"following": {
"followingId-1": true,
"followingId-2": true,
.
.
},
"followers": {
"followerId-1": true,
"followerId-2": true,
.
.
},
"feed": {
"postId-1": true,
"postId-2": true,
.
.
}
},
"userId-2": {},
"userId-3": {},
.
.
}
When somebody posts something, I am also adding the key of that post to the feed of followers of that user.
The problem is that, when somebody starts following someone else, they are not starting to see their older posts. Do you have any idea how to update users timeline immediately after they followed someone?
Note:
This is not a code based problem, its actually a design problem. I am just trying to understand the general idea of user feed in Firebase Database.
Edit:
I am using Java and Spring Framework for my server.
The user feeds are time-ordered. So we need to keep this order while adding and removing references to posts.
Thank you.
If you want to show the historic posts of a user when you start following them, you will need to read those posts at that time. Since your question contains no information on how you store the posts, this is unfortunately as concrete as I can make the answer.
But if we assume that each user also has a list of their own posts, it could be something like (in JavaScript):
function follow(uid) {
var postsRef = ref.child('users').child(uid).child('posts');
var feedRef = ref.child('users').child(auth.uid).child('feed');
postsRef.on('child_added', function(snapshot) {
feedRef.child(snapshot.key).set(true);
});
}

Google Analytics API Multiple Queries - Second Function?

This is a rather newbie question, please bear with me...
I have successfully authorised my Google Analytics API account and am making the following call, which successfully prints the bounce rate.
I want to add more queries on for things such as pageviews and sessions, how do i do this?
It's the functions which are confusing me, do i need to create a new function for each query?
Thanks In Advance!
Tom
function getResults(&$analytics, $profileId) {
// Calls the Core Reporting API and queries for the number of sessions
// for the last seven days.
return $analytics->data_ga->get(
'ga:' . $profileId,
'today',
'today',
'ga:bouncerate');
}
function printResults(&$results) {
// Parses the response from the Core Reporting API and prints
// the profile name and total sessions.
if (count($results->getRows()) > 0) {
// Get the profile name.
$profileName = $results->getProfileInfo()->getProfileName();
// Get the entry for the first entry in the first row.
$rows = $results->getRows();
$sessions = $rows[0][0];
// Print the results.
print "<p>First view (profile) found: $profileName</p>";
print "<p>Total sessions: $sessions</p>";
} else {
print "<p>No results found.</p>";
}
The following part of your code is what actually makes the API request:
$analytics->data_ga->get(
'ga:' . $profileId,
'today',
'today',
'ga:bouncerate');
If you want to make additional queries, you'll have to call the $analytics->data_ga->get() method again. You don't need to write a new function for each query (if you don't want to), but you will need to invoke $analytics->data_ga->get() each time. How you choose to reuse that bit is up to you.

Is there a suitable hook for intercepting all POSTs to an OpenACS/AOLServer system?

I'd like to disable all POSTs to an OpenACS/AOLServer installation. Is there an good singular place – a request-hook or wrapper/middleware – to do this?
(Bonus points if the intercept can let a few URI patterns or logged-in users through.)
Yes, this is straight forward to do. You have a choice here: you can register a proc to run instead of all POSTs, or can you register a filter to run before the POST and filter out certain users or whatever. I think the filter is a better choice.
To do this you register your proc or filter using ns_register_proc or ns_register_filter (with preauth). Put the following code in a .tcl file under the tcl folder of an OpenACS package or under the main AOLserver /web/servername/tcl directory.
Filter example:
ns_register_filter preauth POST / filter_posts
proc filter_posts {} {
set user_id [ad_verify_and_get_user_id]
set list_of_allowed_user_ids [21 567 8999]
if {[lsearch -exact $list_of_allowed_user_ids $user_id] == -1 } {
#this user isn't allowed - so redirect them
ns_returnredirect "/register/"
# tell AOLserver to abort this thread
return filter_return
} else {
# this user is allowed, tell AOLserver to continue
return filter_ok
}
}
Proc example:
ns_register_proc POST / handle_posts
proc handle_posts {} {
ns_returnredirect "http://someotherwebsite.com"
}

Resources