Linkedin api v2 /invitations 403 - api

After authorization with all available permissions(r_basicprofile, r_emailaddress,rw_company_admin, w_share) try to exec request like that
$client->post(
'invitations',
[
'invitee' => "urn:li:person:bQKCsQOZUt",
'message' => [
"com.linkedin.invitations.InvitationMessage" => [
"body" => "Let's connect!"
]
]
]
Get such response
{"serviceErrorCode":100,"message":"Not enough permissions to access: POST /invitations","status":403}

You need to request permissions from LinkedIn to the v2 API.
Submit this form to them with your info: https://business.linkedin.com/marketing-solutions/marketing-partners/become-a-partner/marketing-developer-program
After approval, it should work.

Related

How to upload image to API use HTTP Client laravel 9

Currenlty i'm learning some API. this API require me to upload the image. I'm using laravel 9 to setup the API. but before it, i test the API endpoint on Postman and it works.
here is my postman setting
For integration, i'm using Http Client and this is my first code
$res = Http::withHeaders([
'Authorization' => 'Basic xxxxxxxxx'
])->attach('image', file_get_contents($request->file('image')->getRealPath()))
->post('https://www.website.com/api/send_data', [
'type' => $request->type,
])->json();
this return me error response
$res = Http::withHeaders([
'Authorization' => 'Basic xxxxxxxxx'
])->post('https://www.website.com/api/send_data', [
'multipart'=> [
[
'name'=> 'type',
'contents'=> $request->type,
],
[
'name'=> 'image',
'filename'=> $request->file('image')->getRealPath(),
'Mime-Type'=> $request->file('image')->getClientMimeType(),
'Contents' =>fopen($request->file('image')->getRealPath(), 'r'),
],
]
])->json();
this also return me error response
json_encode error: Type is not supported
What is the correct way to integrate the API on my laravel. please advice

LinkedIn Campagin API Link not inserted

I am using the marketing API to create ads with curl in PHP.
Creating Campaign Groups and Campaigns in this way is working perfectly fine. The basic creation of a creative and an ad is also working. The only problem is that i can’t add a destination URL and some other info’s like the description and Call-to-Action. But the destination URL or content Landing Page like it’s called in the documentation really is fundamental.
This is my code for the creative data:
$data = [
"creative" => [
"inlineContent" => [
"post" => [
"adContext" => [
"dscAdAccount" => "urn:li:sponsoredAccount:".$this->params->get('app.linkedin_my_acc_id'),
"dscStatus" => "ACTIVE"
],
"author" => "urn:li:organization:".$this->params->get('app.linkedin_my_org_id'),
"commentary" => $job->getCommentary(),
"visibility" => "PUBLIC",
"lifecycleState" => "PUBLISHED",
"isReshareDisabledByAuthor" => false,
"contentCallToActionLabel" => "DOWNLOAD",
"contentLandingPage" => "https://google.com",
"content" => [
"media" => [
"title" => "This is a test!",
"id" => $image
]
]
]
],
"campaign" => "urn:li:sponsoredCampaign:".$myCampaignId,
"intendedStatus" => "ACTIVE"
]
];
The structure is the same as in the documentation (https://learn.microsoft.com/en-us/linkedin/marketing/integrations/ads/account-structure/create-and-manage-creatives-new?view=li-lms-2023-01&tabs=http#creatives-inline-schema).
So what am I doing wrong? Why is LinkedIn ignoring my contentLandingPage and contentCallToActionLabel values? The request is working and Im not getting an unpermitted fields error so it seems to be correct…
Can someone help? I also can provide the code of the Campaign Group and the Campaign if needed.
Not sure if this is important but the objectiveType of my Campaign is “WEBSITE_VISIT” and the type is “SPONSORED_UPDATES”.

mailjet send api no composer where to upload the php library?

I am trying to use the mailjet send API for transactional emails from my wordpress website. My mailjet account works fine and I have a contact form that works fine with the mailjet plugin. When the contact form is submitted, an email is sent using mailjet.
Now I want to use the transactional templates from mailjet to replace my actual wp_mail function used in my contact page, because the emails sent using wp_mail doesn't look nice.
I already uploaded the php library (no composer) https://github.com/mailjet/mailjet-apiv3-php-no-composer to my server to the path htdocs/. I created a template on mailjet and published it. The template has the id mentioned in the code below.
This is my code for the send api transactional contact emails.
<form action="" name="contactform" method="post">
...
</form>
<?php
if($emailisright=="OK"){
require_once("/mailjet-apiv3-php-no-composer-master/vendor/autoload.php");
use \src\Mailjet\Resources;
$apikey = '***********************';
$apisecret = '***************************';
$body = [
'Messages' => [
[
'From' => [
'Email' => "no_reply#myemail.com",
'Name' => "Contact mywebsite"
],
'To' => [
[
'Email' => "testemail#gmail.com",
'Name' => "Test email"
]
],
'TemplateID' => 4546355,
'TemplateLanguage' => true,
'Subject' => "Re : contact",
'Variables' => json_decode('{
"name": "Tester",
"mailcc": "testemail#gmail.com",
"message": "test 9"
}', true)
]
]
];
$response = $mj->post(Resources::$Email, ['body' => $body]);
$response->success() && var_dump($response->getData());
}
?>
The page got blank. But when I exclude the following line code //use \src\Mailjet\Resources; then the page renders perfectly, but when submitting the form, I get a broken page which is normal as the line code //use \src\Mailjet\Resources; has been removed. This means that use \src\Mailjet\Resources; seems to be the issue. I also tried with use \Mailjet\Resources; but same broken result.
Now I am not sure I uploaded the php library on the right place on my server. This is the full server path to the wordpress website /opt/bitnami/apps/wordpress/htdocs.
Where do I have to upload the PHP mailjet library?
And where do I have to upload my contact page? On the same level of the mailjet PHP library?

Oauth error invalid_request: Could not find Shopify API application with api_key Shopify error

I am receiving this error immediately after installing my app in my dev store when attempting to exchange the temporary access code for a permanent token.
Oauth error invalid_request: Could not find Shopify API application with api_key
I'm using below code
$client = new Client();
$response = $client->request(
'POST',
"https://{$store}/admin/oauth/access_token",
[
'form_params' => [
'client_id' => $api_key,
'client_secret' => $secret_key,
'code' => $query['code']
]
]
);
$data = json_decode($response->getBody()->getContents(), true);
$access_token = $data['access_token'];
Any help is much appreciated. Thanks!

Devise Token Auth / Angular2-Token, update password, Completed 401 Unauthorized

I'm having troubles restoring password with devise_token_auth. and Angular2-Token. I'm successfully receiving the email with the link to update my password. But I'm getting an 401 Unauthorized response when submiting the new password.
Front end. I'm getting the token from the URL with urlParams.get('token')
onPasswordUpdate() {
let token = this.urlParams.get('token');
var obj = Object.assign(this._updatePasswordData, { reset_password_token: token })
this._tokenService.patch('auth/password/', obj ).subscribe(
res => res,
error => error
);
}
Back end response.
Started PATCH "/api/auth/password/" for 127.0.0.1 at 2016-12-01 21:17:48 +0100
Processing by DeviseTokenAuth::PasswordsController#update as JSON
Parameters: {"reset_password_token"=>"[FILTERED]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}
Completed 401 Unauthorized in 1ms (Views: 0.4ms | ActiveRecord: 0.0ms)
In the link of the email I get the following token : reset_password_token=HneZDoKTMCLF3_SLfnxy
When I visit the link, the user record gets updated with the following attributes :
reset_password_token: "aa3cba76c7b1d8f78cde6856f43e1cce57f5fc8e5301842733de677eff909bc1"
tokens: {}
Then in the browser URL I get the following token=agejaip2SqOp9nvwE1GAHQ&uid
And then the user record get updated with the following attribues :
...
reset_password_token: "HneZDoKTMCLF3_SLfnxy",
tokens: {"pv9i1BDTM29ezep0KSPzpA"=>{"token"=>"$2a$10$cS9gbe9UBICcgphZHRAENOMS6NlEe0Em1cNufY3LSRTPE.hRMabvi", "expiry"=>1481834221}}
...
It seems to me that the token I get back in URL is not correct.
Those anyone have an idea ?
Sorry It's a bit hard to explain.
Many thanks.
rails (4.2.4)
devise_token_auth (0.1.34)
devise (= 3.5.1)
angular2-token: 0.2.0-beta.1
I faced similar challenges recently, and this was how I solved it.
Expose the 'access-token', 'expiry', 'token-type', 'uid', 'client' for your backend. Check here and here
config.middleware.use Rack::Cors do
allow do
origins '*'
resource '*',
:headers => :any,
:expose => ['access-token', 'expiry', 'token-type', 'uid', 'client'],
:methods => => [:get, :post, :options, :delete, :put, :patch]
end
end
Set your redirect_url of path: /password, method: POST. Check info here
We need to modify the reset_password_instructions.html.erb to point it to the api GET /auth/password/edit. More information provided here.
E.g. if your API is under the api namespaces:
<%= link_to 'Change my password', edit_api_user_password_url(reset_password_token: #token, config: message['client-config'].to_s, redirect_url: message['redirect-url'].to_s) %>